Skip to content

Commit 9358cdf

Browse files
committedJan 14, 2015
add a simple test case
1 parent ebe1b0a commit 9358cdf

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
 

‎spec/coffeescripts/wow-spec.coffee

+15
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,17 @@ describe 'WOW', ->
205205

206206
describe 'library behaviour with custom settings', ->
207207

208+
called = false
209+
208210
beforeEach (done) ->
211+
called = false
209212
loadFixtures 'custom.html'
210213
new WOW
211214
boxClass: 'block'
212215
animateClass: 'fancy'
213216
offset: 10
217+
callback: ->
218+
called = true
214219
.init()
215220
setTimeout ->
216221
done()
@@ -293,3 +298,13 @@ describe 'WOW', ->
293298
done()
294299
, timeout
295300
, timeout
301+
302+
it "fires the callback", (done) ->
303+
called = false # reset
304+
# Scroll down so that 150px of #custom-3 becomes visible.
305+
window.scrollTo 0, $('#custom-3').offset().top - winHeight + 150
306+
setTimeout ->
307+
expect called
308+
.toBe true
309+
done()
310+
, timeout

‎spec/javascripts/wow-spec.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,18 @@
140140
});
141141
});
142142
return describe('library behaviour with custom settings', function() {
143+
var called;
144+
called = false;
143145
beforeEach(function(done) {
146+
called = false;
144147
loadFixtures('custom.html');
145148
new WOW({
146149
boxClass: 'block',
147150
animateClass: 'fancy',
148-
offset: 10
151+
offset: 10,
152+
callback: function() {
153+
return called = true;
154+
}
149155
}).init();
150156
return setTimeout(function() {
151157
return done();
@@ -190,7 +196,7 @@
190196
expect($('#custom-3')).not.toHaveClass('fancy');
191197
return expect($('#custom-4')).not.toHaveClass('fancy');
192198
});
193-
return it('animates elements after scrolling down and they become visible', function(done) {
199+
it('animates elements after scrolling down and they become visible', function(done) {
194200
window.scrollTo(0, $('#custom-3').offset().top - winHeight + 150);
195201
return setTimeout(function() {
196202
expect($('#custom-3')).toHaveClass('fancy');
@@ -208,6 +214,14 @@
208214
}, timeout);
209215
}, timeout);
210216
});
217+
return it("fires the callback", function(done) {
218+
called = false;
219+
window.scrollTo(0, $('#custom-3').offset().top - winHeight + 150);
220+
return setTimeout(function() {
221+
expect(called).toBe(true);
222+
return done();
223+
}, timeout);
224+
});
211225
});
212226
});
213227

0 commit comments

Comments
 (0)
Please sign in to comment.