mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
This commit is contained in:
parent
37e90e3dfe
commit
214f5d9fc3
4949 changed files with 1393320 additions and 29 deletions
44
node_modules/videojs-contrib-quality-levels/test/plugin.test.js
generated
vendored
Normal file
44
node_modules/videojs-contrib-quality-levels/test/plugin.test.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
import document from 'global/document';
|
||||
import QUnit from 'qunit';
|
||||
import sinon from 'sinon';
|
||||
import videojs from 'video.js';
|
||||
import plugin from '../src/plugin';
|
||||
|
||||
const Player = videojs.getComponent('Player');
|
||||
|
||||
QUnit.test('the environment is sane', function(assert) {
|
||||
assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
|
||||
assert.strictEqual(typeof sinon, 'object', 'sinon exists');
|
||||
assert.strictEqual(typeof videojs, 'function', 'videojs exists');
|
||||
assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
|
||||
});
|
||||
|
||||
QUnit.module('videojs-contrib-quality-levels', {
|
||||
|
||||
beforeEach() {
|
||||
|
||||
// Mock the environment's timers because certain things - particularly
|
||||
// player readiness - are asynchronous in video.js 5. This MUST come
|
||||
// before any player is created; otherwise, timers could get created
|
||||
// with the actual timer methods!
|
||||
this.clock = sinon.useFakeTimers();
|
||||
|
||||
this.fixture = document.getElementById('qunit-fixture');
|
||||
this.video = document.createElement('video');
|
||||
this.fixture.appendChild(this.video);
|
||||
this.player = videojs(this.video);
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
this.player.dispose();
|
||||
this.clock.restore();
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('registers itself with video.js', function(assert) {
|
||||
assert.strictEqual(
|
||||
typeof Player.prototype.qualityLevels,
|
||||
'function',
|
||||
'videojs-contrib-quality-levels plugin was registered'
|
||||
);
|
||||
});
|
123
node_modules/videojs-contrib-quality-levels/test/quality-level-list.test.js
generated
vendored
Normal file
123
node_modules/videojs-contrib-quality-levels/test/quality-level-list.test.js
generated
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
import QUnit from 'qunit';
|
||||
import QualityLevelList from '../src/quality-level-list';
|
||||
import { representations } from './test-helpers';
|
||||
|
||||
QUnit.module('QualityLevelList', {
|
||||
beforeEach() {
|
||||
this.qualityLevels = new QualityLevelList();
|
||||
this.levels = representations;
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('Properly adds QualityLevels to the QualityLevelList', function(assert) {
|
||||
let addCount = 0;
|
||||
|
||||
this.qualityLevels.on('addqualitylevel', (event) => {
|
||||
addCount++;
|
||||
});
|
||||
|
||||
const expected0 = this.qualityLevels.addQualityLevel(this.levels[0]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 1, 'added quality level');
|
||||
assert.equal(addCount, 1, 'emmitted addqualitylevel event');
|
||||
assert.strictEqual(this.qualityLevels[0], expected0, 'can access quality level with index');
|
||||
|
||||
const expected1 = this.qualityLevels.addQualityLevel(this.levels[1]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 2, 'added quality level');
|
||||
assert.equal(addCount, 2, 'emmitted addqualitylevel event');
|
||||
assert.strictEqual(this.qualityLevels[1], expected1, 'can access quality level with index');
|
||||
|
||||
const expectedDuplicate = this.qualityLevels.addQualityLevel(this.levels[0]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 2, 'does not add duplicate quality level');
|
||||
assert.equal(addCount, 2, 'no event emitted on dulicate');
|
||||
assert.strictEqual(this.qualityLevels[3], undefined, 'no index property defined');
|
||||
assert.strictEqual(this.qualityLevels[0], expected0, 'quality level unchanged');
|
||||
assert.strictEqual(this.qualityLevels[0], expectedDuplicate, 'adding duplicate returns same reference');
|
||||
assert.strictEqual(this.qualityLevels[1], expected1, 'quality level unchanged');
|
||||
});
|
||||
|
||||
QUnit.test('Properly removes QualityLevels from the QualityLevelList', function(assert) {
|
||||
let removeCount = 0;
|
||||
const expected = [];
|
||||
|
||||
this.levels.forEach((qualityLevel) => {
|
||||
expected.push(this.qualityLevels.addQualityLevel(qualityLevel));
|
||||
});
|
||||
|
||||
this.qualityLevels.on('removequalitylevel', (event) => {
|
||||
removeCount++;
|
||||
});
|
||||
|
||||
// Mock an initial selected quality level
|
||||
this.qualityLevels.selectedIndex_ = 2;
|
||||
|
||||
assert.equal(this.qualityLevels.length, 4, '4 initial quality levels');
|
||||
|
||||
let removed = this.qualityLevels.removeQualityLevel(expected[3]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 3, 'removed quality level');
|
||||
assert.equal(removeCount, 1, 'emitted removequalitylevel event');
|
||||
assert.strictEqual(removed, expected[3], 'returned removed level');
|
||||
assert.notStrictEqual(this.qualityLevels[3], expected[3], 'nothing at index');
|
||||
|
||||
removed = this.qualityLevels.removeQualityLevel(expected[1]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 2, 'removed quality level');
|
||||
assert.equal(removeCount, 2, 'emitted removequalitylevel event');
|
||||
assert.strictEqual(removed, expected[1], 'returned removed level');
|
||||
assert.notStrictEqual(this.qualityLevels[1], expected[1], 'quality level not at index');
|
||||
assert.strictEqual(
|
||||
this.qualityLevels[this.qualityLevels.selectedIndex],
|
||||
expected[2],
|
||||
'selected index properly adjusted on quality level removal'
|
||||
);
|
||||
|
||||
removed = this.qualityLevels.removeQualityLevel(expected[3]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 2, 'no quality level removed if not found');
|
||||
assert.equal(removed, null, 'returned null when nothing removed');
|
||||
assert.equal(removeCount, 2, 'no event emitted when quality level not found');
|
||||
|
||||
removed = this.qualityLevels.removeQualityLevel(expected[2]);
|
||||
|
||||
assert.equal(this.qualityLevels.length, 1, 'quality level removed');
|
||||
assert.equal(removeCount, 3, 'emitted removequalitylevel event');
|
||||
assert.strictEqual(removed, expected[2], 'returned removed level');
|
||||
assert.equal(this.qualityLevels.selectedIndex, -1, 'selectedIndex set to -1 when removing selected quality level');
|
||||
});
|
||||
|
||||
QUnit.test('can get quality level by id', function(assert) {
|
||||
const expected = [];
|
||||
|
||||
this.levels.forEach((qualityLevel) => {
|
||||
expected.push(this.qualityLevels.addQualityLevel(qualityLevel));
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
this.qualityLevels.getQualityLevelById('0'),
|
||||
expected[0],
|
||||
'found quality level with id "0"'
|
||||
);
|
||||
assert.strictEqual(
|
||||
this.qualityLevels.getQualityLevelById('1'),
|
||||
expected[1],
|
||||
'found quality level with id "1"'
|
||||
);
|
||||
assert.strictEqual(
|
||||
this.qualityLevels.getQualityLevelById('2'),
|
||||
expected[2],
|
||||
'found quality level with id "2"'
|
||||
);
|
||||
assert.strictEqual(
|
||||
this.qualityLevels.getQualityLevelById('3'),
|
||||
expected[3],
|
||||
'found quality level with id "3"'
|
||||
);
|
||||
assert.strictEqual(
|
||||
this.qualityLevels.getQualityLevelById('4'),
|
||||
null,
|
||||
'no quality level with id "4" found'
|
||||
);
|
||||
});
|
42
node_modules/videojs-contrib-quality-levels/test/test-helpers.js
generated
vendored
Normal file
42
node_modules/videojs-contrib-quality-levels/test/test-helpers.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
export const representations = [
|
||||
{
|
||||
id: '0',
|
||||
width: 100,
|
||||
height: 100,
|
||||
bandwidth: 100,
|
||||
frameRate: 29.956,
|
||||
enabled() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '1',
|
||||
width: 200,
|
||||
height: 200,
|
||||
bandwidth: 200,
|
||||
frameRate: 29.956,
|
||||
enabled() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
width: 300,
|
||||
height: 300,
|
||||
bandwidth: 300,
|
||||
frameRate: 30,
|
||||
enabled() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
width: 400,
|
||||
height: 400,
|
||||
bandwidth: 400,
|
||||
frameRate: 60,
|
||||
enabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue