Skip to content

Commit

Permalink
fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
attilaolah committed Feb 3, 2014
1 parent 951c8a0 commit c1e8e82
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
38 changes: 28 additions & 10 deletions spec/coffeescripts/wow-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ describe "WOW", ->
.not.toHaveClass "animated"

it "animates elements after scrolling down and they become visible", (done) ->
window.scrollTo 0, $("#simple-3").offset().top-winHeight+150
# Scroll down so that 150px of #simple-3 becomes visible.
window.scrollTo 0, $("#simple-3").offset().top - winHeight + 150
setTimeout ->
expect $ "#simple-3"
.toHaveClass "animated"
expect $ "#simple-4"
.not.toHaveClass "animated"
window.scrollTo 0, $("#simple-4").offset().top-winHeight+150
# Scroll down so that 150px of #simple-4 becomes visible.
window.scrollTo 0, $("#simple-4").offset().top - winHeight + 150
setTimeout ->
expect $ "#simple-4"
.toHaveClass "animated"
Expand Down Expand Up @@ -132,15 +134,29 @@ describe "WOW", ->
done()
, timeout

it "does not touch elements that don't have the marker class", ->
window.scrollTo 0, $("#custom-1").offset().top - 10
expect $ "#custom-1"
.not.toHaveClass "fancy"
it "does not touch elements that don't have the marker class", (done) ->
# Scroll down so that 15px of #custom-1 becomes visible.
window.scrollTo 0, $("#custom-1").offset().top - winHeight + 15
setTimeout ->
expect $ "#custom-1"
.not.toHaveClass "fancy"
done()
, timeout

it "animates elements that are partially visible on the page", ->
window.scrollTo 0, $("#custom-2").offset().top - winHeight + 10
expect $ "#custom-2"
.toHaveClass "fancy"
it "animates elements that are partially visible on the page based on the 'offset' config", (done) ->
setTimeout ->
# Scroll down so that 5px of #custom-2 becomes visible.
window.scrollTo 0, $("#custom-2").offset().top - winHeight + 5
expect $ "#custom-2"
.not.toHaveClass "fancy"
window.scrollTo 0, $("#custom-2").offset().top - winHeight + 15
setTimeout ->
# Scroll down so that 15px of #custom-2 becomes visible.
expect $ "#custom-2"
.toHaveClass "fancy"
done()
, timeout
, timeout

it "does not animate elements not yet visible on the page", ->
expect $ "#custom-3"
Expand All @@ -149,6 +165,7 @@ describe "WOW", ->
.not.toHaveClass "fancy"

it "animates elements after scrolling down and they become visible", (done) ->
# Scroll down so that 150px of #custom-3 becomes visible.
window.scrollTo 0, $("#custom-3").offset().top - winHeight + 150
setTimeout ->
expect $ "#custom-3"
Expand All @@ -157,6 +174,7 @@ describe "WOW", ->
.toBe "2"
expect $ "#custom-4"
.not.toHaveClass "fancy"
# Scroll down so that 150px of #custom-4 becomes visible.
window.scrollTo 0, $("#custom-4").offset().top - winHeight + 150
setTimeout ->
expect $ "#custom-4"
Expand Down
22 changes: 16 additions & 6 deletions spec/javascripts/wow-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,23 @@
return done();
}, timeout);
});
it("does not touch elements that don't have the marker class", function() {
window.scrollTo(0, $("#custom-1").offset().top - 10);
return expect($("#custom-1")).not.toHaveClass("fancy");
it("does not touch elements that don't have the marker class", function(done) {
window.scrollTo(0, $("#custom-1").offset().top - winHeight + 15);
return setTimeout(function() {
expect($("#custom-1")).not.toHaveClass("fancy");
return done();
}, timeout);
});
it("animates elements that are partially visible on the page", function() {
window.scrollTo(0, $("#custom-2").offset().top - winHeight + 10);
return expect($("#custom-2")).toHaveClass("fancy");
it("animates elements that are partially visible on the page based on the 'offset' config", function(done) {
return setTimeout(function() {
window.scrollTo(0, $("#custom-2").offset().top - winHeight + 5);
expect($("#custom-2")).not.toHaveClass("fancy");
window.scrollTo(0, $("#custom-2").offset().top - winHeight + 15);
return setTimeout(function() {
expect($("#custom-2")).toHaveClass("fancy");
return done();
}, timeout);
}, timeout);
});
it("does not animate elements not yet visible on the page", function() {
expect($("#custom-3")).not.toHaveClass("fancy");
Expand Down

0 comments on commit c1e8e82

Please sign in to comment.