Skip to content

Commit 17811a9

Browse files
committed
i.e. tests fixes
1 parent 5e28daf commit 17811a9

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

spec/spriter.coffee

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,19 @@ describe 'Spriter module ->', ->
193193
sp = new Spriter el: div, isRunLess: true
194194
spyOn sp._props, 'onUpdate'
195195
sp._tween.setProgress(.5)
196-
expect(sp._props.onUpdate).toHaveBeenCalledWith(.5)
196+
expect(sp._props.onUpdate).toHaveBeenCalled()
197+
it 'should be called with progress on every sprite update', ->
198+
div = document.createElement('div')
199+
div1 = document.createElement('div'); div2 = document.createElement('div')
200+
div3 = document.createElement('div'); div4 = document.createElement('div')
201+
div.appendChild(div1); div.appendChild(div2); div.appendChild(div3)
202+
div.appendChild(div4)
203+
progress = -1
204+
sp = new Spriter
205+
el: div, isRunLess: true
206+
onUpdate: (p)-> progress = p
207+
sp._tween.setProgress(.5)
208+
expect(progress.toFixed(1)).toBe '0.5'
197209

198210
describe 'run method', ->
199211
it 'should start tween', ->

spec/spriter.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
});
298298
});
299299
describe('onUpdate callback', function() {
300-
return it('should be called on every sprite update', function() {
300+
it('should be called on every sprite update', function() {
301301
var div, div1, div2, div3, div4, sp;
302302
div = document.createElement('div');
303303
div1 = document.createElement('div');
@@ -314,7 +314,29 @@
314314
});
315315
spyOn(sp._props, 'onUpdate');
316316
sp._tween.setProgress(.5);
317-
return expect(sp._props.onUpdate).toHaveBeenCalledWith(.5);
317+
return expect(sp._props.onUpdate).toHaveBeenCalled();
318+
});
319+
return it('should be called with progress on every sprite update', function() {
320+
var div, div1, div2, div3, div4, progress, sp;
321+
div = document.createElement('div');
322+
div1 = document.createElement('div');
323+
div2 = document.createElement('div');
324+
div3 = document.createElement('div');
325+
div4 = document.createElement('div');
326+
div.appendChild(div1);
327+
div.appendChild(div2);
328+
div.appendChild(div3);
329+
div.appendChild(div4);
330+
progress = -1;
331+
sp = new Spriter({
332+
el: div,
333+
isRunLess: true,
334+
onUpdate: function(p) {
335+
return progress = p;
336+
}
337+
});
338+
sp._tween.setProgress(.5);
339+
return expect(progress.toFixed(1)).toBe('0.5');
318340
});
319341
});
320342
return describe('run method', function() {

0 commit comments

Comments
 (0)