mirror of
https://github.com/videojs/video.js.git
synced 2024-12-12 11:15:04 +02:00
a8ff970d4a
Broke out bind, guid, and element data functions from Lib Separated out more dom functions in to dom.js Broke out URL functions into url.js Removed setLocalStorage since it wasn't being used Moved browser tests out of lib Moved log functions into their own file Removed trim() since it wasn't being used Moved formatTime into its own file Moved round into its own file and renamed roundFloat() Moved capitalize into its own file and renamed as toTitleCase() Moved createTimeRange into its own file Removed Lib.arr.forEach infavor of the native forEach Removed Lib.obj.create in favor of native Object.create (ES6-sham) Removed obj.each in favor of native Object.getOwnPropertyNames().forEach() Removed obj.merge and copy. Using lodash.assign instead. Replaced Lib.obj.isPlain with lodash.isPlainObject Removed Lib.obj.isArray in favor of the native Array.isArray Also removed the lib.js tests file as all tests have been moved or removed. Removed Lib.isEmpty in favor of !Object.getOwnPropertyNames().length Switched Util.mergeOptions and deepMerge to use new mergeOptions() Moved Lib.TEST_VID to Html5.TEST_VID Removed Lib references everywhere. Woo! Attempting to fix sourcemap test errors by setting grunt-browserify version Switched to object.assign from lodash.assign Removed unused 'inherits' dependency Reorganzied test files and added '.test' to file names Combined js/core.js and js/video.js Moved events.js into the utils directory
91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
import TextTrackCueList from '../../../src/js/tracks/text-track-cue-list.js';
|
|
|
|
let genericTracks = [
|
|
{
|
|
id: '1'
|
|
}, {
|
|
id: '2'
|
|
}, {
|
|
id: '3'
|
|
}
|
|
];
|
|
|
|
q.module('Text Track Cue List');
|
|
|
|
test('TextTrackCueList\'s length is set correctly', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
equal(ttcl.length, genericTracks.length, 'the length is ' + genericTracks.length);
|
|
});
|
|
|
|
test('can get cues by id', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
equal(ttcl.getCueById('1').id, 1, 'id "1" has id of "1"');
|
|
equal(ttcl.getCueById('2').id, 2, 'id "2" has id of "2"');
|
|
equal(ttcl.getCueById('3').id, 3, 'id "3" has id of "3"');
|
|
ok(!ttcl.getCueById(1), 'there isn\'t an item with "numeric" id of `1`');
|
|
});
|
|
|
|
test('length is updated when new tracks are added or removed', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}]));
|
|
equal(ttcl.length, genericTracks.length + 1, 'the length is ' + (genericTracks.length + 1));
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}, {id: '101'}]));
|
|
equal(ttcl.length, genericTracks.length + 2, 'the length is ' + (genericTracks.length + 2));
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}]));
|
|
equal(ttcl.length, genericTracks.length + 1, 'the length is ' + (genericTracks.length + 1));
|
|
ttcl.setCues_(genericTracks);
|
|
equal(ttcl.length, genericTracks.length, 'the length is ' + genericTracks.length);
|
|
});
|
|
|
|
test('can access items by index', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks),
|
|
i = 0,
|
|
length = ttcl.length;
|
|
|
|
expect(length);
|
|
|
|
for (; i < length; i++) {
|
|
equal(ttcl[i].id, String(i + 1), 'the id of a track matches the index + 1');
|
|
}
|
|
});
|
|
|
|
test('can access new items by index', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}]));
|
|
|
|
equal(ttcl[3].id, '100', 'id of item at index 3 is 100');
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}, {id: '101'}]));
|
|
equal(ttcl[4].id, '101', 'id of item at index 4 is 101');
|
|
});
|
|
|
|
test('cannot access removed items by index', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}, {id: '101'}]));
|
|
equal(ttcl[3].id, '100', 'id of item at index 3 is 100');
|
|
equal(ttcl[4].id, '101', 'id of item at index 4 is 101');
|
|
|
|
ttcl.setCues_(genericTracks);
|
|
|
|
ok(!ttcl[3], 'nothing at index 3');
|
|
ok(!ttcl[4], 'nothing at index 4');
|
|
});
|
|
|
|
test('new item available at old index', function() {
|
|
var ttcl = new TextTrackCueList(genericTracks);
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '100'}]));
|
|
equal(ttcl[3].id, '100', 'id of item at index 3 is 100');
|
|
|
|
ttcl.setCues_(genericTracks);
|
|
ok(!ttcl[3], 'nothing at index 3');
|
|
|
|
ttcl.setCues_(genericTracks.concat([{id: '101'}]));
|
|
equal(ttcl[3].id, '101', 'id of new item at index 3 is now 101');
|
|
});
|