@@ -116,8 +116,16 @@ describe('element.applyProps', () => {
116
116
const element = createElement ( TYPES . Sprite , { image : './image.png' } )
117
117
expect ( spy ) . lastCalledWith ( './image.png' )
118
118
119
- element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
119
+ const changed = element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
120
120
expect ( spy ) . lastCalledWith ( './new-image.png' )
121
+ expect ( changed ) . toBeFalsy ( )
122
+ } )
123
+
124
+ test ( 'Sprite.applyProps texture' , ( ) => {
125
+ const element = createElement ( TYPES . Sprite , { texture : emptyTexture } )
126
+
127
+ const changed = element . applyProps ( element , { texture : emptyTexture } , { image : './image.png' } )
128
+ expect ( changed ) . toBeTruthy ( )
121
129
} )
122
130
123
131
test ( 'TilingSprite.applyProps exists' , ( ) => {
@@ -130,10 +138,28 @@ describe('element.applyProps', () => {
130
138
const element = createElement ( TYPES . TilingSprite , { image : './image.png' } )
131
139
expect ( spy ) . lastCalledWith ( './image.png' )
132
140
133
- element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
141
+ const changed = element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
142
+ expect ( changed ) . toBeFalsy ( )
134
143
expect ( spy ) . lastCalledWith ( './new-image.png' )
135
144
} )
136
145
146
+ test ( 'TilingSprite.applyProps texture' , ( ) => {
147
+ const element = createElement ( TYPES . TilingSprite , { texture : emptyTexture } )
148
+
149
+ const changed = element . applyProps ( element , { texture : emptyTexture } , { image : './image.png' } )
150
+ expect ( changed ) . toBeTruthy ( )
151
+ } )
152
+
153
+ test ( 'TilingSprite.applyProps tilePosition' , ( ) => {
154
+ const oldPosition = '1, 2'
155
+ const newPosition = { x : 12 , y : 20 }
156
+ const element = createElement ( TYPES . TilingSprite , { tilePosition : oldPosition , image : './image.png' } )
157
+
158
+ const changed = element . applyProps ( element , { tilePosition : oldPosition , image : './image.png' } , { tilePosition : newPosition , image : './image.png' } )
159
+ expect ( changed ) . toBeTruthy ( )
160
+ } )
161
+
162
+
137
163
test ( 'SimpleRope.applyProps exists' , ( ) => {
138
164
const element = createElement ( TYPES . SimpleRope , {
139
165
image : './image.png' ,
@@ -150,7 +176,7 @@ describe('element.applyProps', () => {
150
176
} )
151
177
expect ( spy ) . lastCalledWith ( './image.png' )
152
178
153
- element . applyProps (
179
+ const changed = element . applyProps (
154
180
element ,
155
181
{ image : './image.png' } ,
156
182
{
@@ -159,6 +185,7 @@ describe('element.applyProps', () => {
159
185
}
160
186
)
161
187
expect ( spy ) . lastCalledWith ( './new-image.png' )
188
+ expect ( changed ) . toBeTruthy ( )
162
189
} )
163
190
164
191
test ( 'NineSlicePlane.applyProps exists' , ( ) => {
@@ -171,8 +198,15 @@ describe('element.applyProps', () => {
171
198
const element = createElement ( TYPES . NineSlicePlane , { image : './image.png' } )
172
199
expect ( spy ) . lastCalledWith ( './image.png' )
173
200
174
- element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
201
+ const changed = element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
175
202
expect ( spy ) . lastCalledWith ( './new-image.png' )
203
+ expect ( changed ) . toBeFalsy ( )
204
+ } )
205
+
206
+ test ( 'NineSlicePlane.applyProps texture' , ( ) => {
207
+ const element = createElement ( TYPES . NineSlicePlane , { texture : emptyTexture } )
208
+ const changed = element . applyProps ( element , { texture : emptyTexture } , { image : './new-image.png' } )
209
+ expect ( changed ) . toBeTruthy ( )
176
210
} )
177
211
178
212
test ( 'SimpleMesh.applyProps exists' , ( ) => {
@@ -185,8 +219,16 @@ describe('element.applyProps', () => {
185
219
const element = createElement ( TYPES . SimpleMesh , { image : './image.png' } )
186
220
expect ( spy ) . lastCalledWith ( './image.png' )
187
221
188
- element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
222
+ let changed = element . applyProps ( element , { image : './image.png' } , { image : './new-image.png' } )
189
223
expect ( spy ) . lastCalledWith ( './new-image.png' )
224
+ expect ( changed ) . toBeFalsy ( )
225
+ } )
226
+
227
+ test ( 'SimpleMesh.applyProps texture' , ( ) => {
228
+ const element = createElement ( TYPES . SimpleMesh , { texture : emptyTexture } )
229
+
230
+ let changed = element . applyProps ( element , { texture : emptyTexture } , { image : './new-image.png' } )
231
+ expect ( changed ) . toBeTruthy ( )
190
232
} )
191
233
192
234
test ( 'Graphics.applyProps exists' , ( ) => {
@@ -203,21 +245,27 @@ describe('element.applyProps', () => {
203
245
const element = createElement ( TYPES . Graphics , { draw : spy } )
204
246
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
205
247
206
- element . applyProps ( element , { draw : spy } , { draw : spy } )
248
+ const applied = element . applyProps ( element , { draw : spy } , { draw : spy } )
207
249
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
250
+ expect ( applied ) . toBeFalsy ( )
208
251
} )
209
252
210
253
test ( 'Graphics.applyProps draw prevented twice' , ( ) => {
211
254
const draw1 = jest . fn ( )
212
255
const draw2 = jest . fn ( )
213
256
const props = { draw : draw1 }
214
257
const nextProps = { draw : draw2 }
258
+ let applied = false ;
215
259
const element = createElement ( TYPES . Graphics , props )
216
- element . applyProps ( element , props , props )
217
- element . applyProps ( element , props , props )
260
+ applied = element . applyProps ( element , props , props )
261
+ expect ( applied ) . toBeFalsy ( )
262
+ applied = element . applyProps ( element , props , props )
263
+ expect ( applied ) . toBeFalsy ( )
218
264
expect ( draw1 ) . toHaveBeenCalledTimes ( 1 )
219
- element . applyProps ( element , props , nextProps )
220
- element . applyProps ( element , nextProps , nextProps )
265
+ applied = element . applyProps ( element , props , nextProps )
266
+ expect ( applied ) . toBeTruthy ( )
267
+ applied = element . applyProps ( element , nextProps , nextProps )
268
+ expect ( applied ) . toBeFalsy ( )
221
269
expect ( draw2 ) . toHaveBeenCalledTimes ( 1 )
222
270
} )
223
271
} )
0 commit comments