forked from mozilla/popcorn-js
-
Notifications
You must be signed in to change notification settings - Fork 7
/
popcorn.parserSBV.unit.js
58 lines (48 loc) · 1.29 KB
/
popcorn.parserSBV.unit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
test( "Popcorn 0.3 SBV Parser Plugin", function () {
var count = 0,
numSubs = 0,
sub,
poppercorn = Popcorn( "#video" ),
subs = [
{
text: "Senator, we're making our final approach into Coruscant.",
start: 2.4,
end: 7.2
},
{
text: "Very good, Lieutenant.",
start: 9.712,
end: 13.399
},
{
text: "It's a trap!",
start: 15.042,
end: 18.042
}
],
expects = subs.length*3 + 1;
function plus() {
if ( ++count === expects ) {
start();
}
}
poppercorn.parseSBV( "data/data.sbv" );
expect(expects);
stop( 5000 );
// Allow load time
setTimeout(function () {
Popcorn.forEach( poppercorn.getTrackEvents(), function(evt) {
if( evt._natives.type === "subtitle" ) {
sub = subs[numSubs++];
equals( evt.start, sub.start, "Correctly parsed start of " + evt.start );
plus();
equals( evt.text, sub.text, "Correctly parsed text of " + evt.start );
plus();
equals( evt.end, sub.end, "Correctly parsed end at " + evt.start );
plus();
}
});
equals( subs.length, numSubs, "Parsed all subtitles" );
plus();
}, 500);
});