Permalink
Browse files

Merge pull request #19 from dseif/t986

[#986] Wordriver failing on testswarm
  • Loading branch information...
2 parents a7d9d38 + 95178f3 commit a5478ad07deda1e310c62d8ee0c237ffde1a83b3 @dseif dseif committed May 3, 2012
Showing with 54 additions and 32 deletions.
  1. +54 −32 plugins/wordriver/popcorn.wordriver.unit.js
@@ -5,6 +5,9 @@ test( "Popcorn wordriver Plugin", function() {
count = 0,
firstTrack,
secondTrack,
+ firstCue,
+ secondCue,
+ thirdCue,
wordriverdiv = document.getElementById( "wordriverdiv" );
expect( expects );
@@ -24,87 +27,106 @@ test( "Popcorn wordriver Plugin", function() {
plus();
popped.wordriver({
- start: 0,
- end: 2,
- text: "hello",
- target: "wordriverdiv",
- color: "red"
+ start: 0,
+ end: 2,
+ text: "hello",
+ target: "wordriverdiv",
+ color: "red"
});
firstTrack = popped.getLastTrackEventId();
popped.wordriver({
- start: 2,
- end: 4,
- text: "world",
- target: "wordriverdiv",
- color: "blue"
+ start: 2,
+ end: 4,
+ text: "world",
+ target: "wordriverdiv",
+ color: "blue"
});
secondTrack = popped.getLastTrackEventId();
popped.wordriver({
- start: 20,
- end: 24,
- text: "nothing here",
- target: "wordriverdiv",
- color: "green"
+ start: 20,
+ end: 24,
+ text: "nothing here",
+ target: "wordriverdiv",
+ color: "green"
})
.volume( 0 );
- popped.exec( 0, function() {
- equal( wordriverdiv.children[ 0 ].childElementCount, 1, "wordriverdiv now has one inner element" );
+ popped.cue( 0, function() {
+ var child = wordriverdiv.children[ 0 ],
+ subChildren = child.children;
+
+ // need to do this here because we fire the event
+ // as soon as we can, as it starts at 0
+ firstCue = popped.getLastTrackEventId();
+ equal( child.childElementCount, 1, "wordriverdiv now has one inner element" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 0 ].style.opacity, 1, "first word is visible on the page" );
+ equal( subChildren[ 0 ].style.opacity, 1, "first word is visible on the page" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 0 ].innerHTML, "hello", "first word content is correct" );
+ equal( subChildren[ 0 ].innerHTML, "hello", "first word content is correct" );
plus();
- ok( !wordriverdiv.children[ 0 ].children[ 1 ], "second word does not exist yet" );
+ ok( !subChildren[ 1 ], "second word does not exist yet" );
plus();
+ popped.removeTrackEvent( firstCue );
});
- popped.exec( 2, function() {
- equal( wordriverdiv.children[ 0 ].childElementCount, 2, "wordriverdiv now has two inner elements" );
+ popped.cue( 2, function() {
+ var child = wordriverdiv.children[ 0 ],
+ subChildren = child.children;
+
+ equal( child.childElementCount, 2, "wordriverdiv now has two inner elements" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 0 ].style.opacity, 0, "first word is not visible on the page" );
+ equal( subChildren[ 0 ].style.opacity, 0, "first word is not visible on the page" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 0 ].innerHTML, "hello", "first word content is correct" );
+ equal( subChildren[ 0 ].innerHTML, "hello", "first word content is correct" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 1 ].style.opacity, 1, "second word is visible on the page" );
+ equal( subChildren[ 1 ].style.opacity, 1, "second word is visible on the page" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 1 ].innerHTML, "world", "second word content is correct" );
+ equal( subChildren[ 1 ].innerHTML, "world", "second word content is correct" );
plus();
+ popped.removeTrackEvent( secondCue );
});
- popped.exec( 4, function() {
- equal( wordriverdiv.children[ 0 ].children[ 0 ].style.opacity, 0, "first word is not visible on the page" );
+ secondCue = popped.getLastTrackEventId();
+
+ popped.cue( 4, function() {
+ var child = wordriverdiv.children[ 0 ],
+ subChildren = child.children;
+
+ equal( subChildren[ 0 ].style.opacity, 0, "first word is not visible on the page" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 1 ].style.opacity, 0, "second word is not visible on the page" );
+ equal( subChildren[ 1 ].style.opacity, 0, "second word is not visible on the page" );
plus();
popped.pause().removeTrackEvent( firstTrack );
- equal( wordriverdiv.children[ 0 ].childElementCount, 1, "wordriverdiv now has one inner element" );
+ equal( child.childElementCount, 1, "wordriverdiv now has one inner element" );
plus();
- equal( wordriverdiv.children[ 0 ].children[ 0 ].innerHTML, "world", "first word content is changed" );
+ equal( subChildren[ 0 ].innerHTML, "world", "first word content is changed" );
plus();
popped.pause().removeTrackEvent( secondTrack );
equal( wordriverdiv.childElementCount, 0, "wordriverdiv now has no inner element, even though one still exists, but was never called" );
plus();
+ popped.removeTrackEvent( thirdCue );
});
+ thirdCue = popped.getLastTrackEventId();
+
// empty track events should be safe
popped.wordriver({});
// debug should log errors on empty track events
Popcorn.plugin.debug = true;
try {
popped.wordriver({});
+ ok( false, "empty event was not caught by debug" );
} catch( e ) {
ok( true, "empty event was caught by debug" );
plus();
}
popped.play();
-
});

0 comments on commit a5478ad

Please sign in to comment.