hls-audio-track.test.js
2.93 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import HlsAudioTrack from '../src/hls-audio-track';
import QUnit from 'qunit';
// Most of these tests will be done in video.js.AudioTrack unit tests
QUnit.module('HlsAudioTrack - Props');
QUnit.test('verify that props are readonly and can be set', function() {
let props = {
default: true,
language: 'en',
label: 'English',
autoselect: true,
withCredentials: true,
// below props won't be used, its used for checking
kind: 'main'
};
let track = new HlsAudioTrack(props);
for (let k in props) {
QUnit.equal(track[k], props[k], `${k} should be stored in track`);
}
});
QUnit.test('can start with a mediaGroup that has a uri', function() {
let props = {
default: true,
language: 'en',
label: 'English',
autoselect: true,
mediaGroup: 'foo',
withCredentials: true,
resolvedUri: 'http://some.test.url/playlist.m3u8',
// below props won't be used, its used for checking
enabled: true,
kind: 'main'
};
let track = new HlsAudioTrack(props);
QUnit.equal(track.mediaGroups_.length, 1, 'loader was created');
let loader = track.getLoader('foo');
QUnit.ok(loader, 'can getLoader on foo');
track.dispose();
QUnit.equal(track.mediaGroups_.length, 0, 'loader disposed');
});
QUnit.test('can start with a mediaGroup that has no uri', function() {
let props = {
default: true,
language: 'en',
label: 'English',
autoselect: true,
mediaGroup: 'foo',
withCredentials: true,
// below props won't be used, its used for checking
enabled: true,
kind: 'main'
};
let track = new HlsAudioTrack(props);
QUnit.equal(track.mediaGroups_.length, 1, 'mediaGroupLoader was created for foo');
QUnit.ok(!track.getLoader('foo'), 'can getLoader on foo, but it is undefined');
track.dispose();
QUnit.equal(track.mediaGroups_.length, 0, 'loaders disposed');
});
QUnit.module('HlsAudioTrack - Loader', {
beforeEach() {
this.track = new HlsAudioTrack({
mediaGroup: 'default',
default: true,
language: 'en',
label: 'English',
autoselect: true,
withCredentials: true
});
},
afterEach() {
this.track.dispose();
QUnit.equal(this.track.mediaGroups_.length, 0, 'zero loaders after dispose');
}
});
QUnit.test('can add a playlist loader', function() {
QUnit.equal(this.track.mediaGroups_.length, 1, '1 loader to start');
this.track.addLoader('foo', 'someurl');
this.track.addLoader('bar', 'someurl');
this.track.addLoader('baz', 'someurl');
QUnit.equal(this.track.mediaGroups_.length, 4, 'now has four loaders');
});
QUnit.test('can remove playlist loader', function() {
QUnit.equal(this.track.mediaGroups_.length, 1, 'one loaders to start');
this.track.addLoader('foo', 'someurl');
this.track.addLoader('baz', 'someurl');
QUnit.equal(this.track.mediaGroups_.length, 3, 'now has three loaders');
this.track.removeLoader('baz');
QUnit.equal(this.track.mediaGroups_.length, 2, 'now has two loaders');
});