|
|
|
@ -31,8 +31,10 @@ QUnit.module('Component', {
|
|
|
|
|
},
|
|
|
|
|
beforeEach() {
|
|
|
|
|
this.clock = sinon.useFakeTimers();
|
|
|
|
|
this.player = TestHelpers.makePlayer();
|
|
|
|
|
},
|
|
|
|
|
afterEach() {
|
|
|
|
|
this.player.dispose();
|
|
|
|
|
this.clock.restore();
|
|
|
|
|
},
|
|
|
|
|
after() {
|
|
|
|
@ -43,16 +45,6 @@ QUnit.module('Component', {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getFakePlayer = function() {
|
|
|
|
|
return {
|
|
|
|
|
// Fake player requries an ID
|
|
|
|
|
id() {
|
|
|
|
|
return 'player_1';
|
|
|
|
|
},
|
|
|
|
|
reportUserActivity() {}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QUnit.test('registerComponent() throws with bad arguments', function(assert) {
|
|
|
|
|
assert.throws(
|
|
|
|
|
function() {
|
|
|
|
@ -92,7 +84,7 @@ QUnit.test('registerComponent() throws with bad arguments', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should create an element', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
assert.ok(comp.el().nodeName);
|
|
|
|
|
|
|
|
|
@ -100,7 +92,7 @@ QUnit.test('should create an element', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add a child component', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
const child = comp.addChild('component');
|
|
|
|
|
|
|
|
|
@ -114,7 +106,7 @@ QUnit.test('should add a child component', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add a child component to an index', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
const child = comp.addChild('component');
|
|
|
|
|
|
|
|
|
@ -151,7 +143,7 @@ QUnit.test('should insert element relative to the element of the component to in
|
|
|
|
|
// for legibility of the test itself:
|
|
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
const child0 = comp.addChild('component', {el: Dom.createEl('div', {}, {class: 'c0'})});
|
|
|
|
|
const child1 = comp.addChild('component', {createEl: false});
|
|
|
|
@ -169,7 +161,7 @@ QUnit.test('should allow for children that are elements', function(assert) {
|
|
|
|
|
// for legibility of the test itself:
|
|
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const testEl = Dom.createEl('div');
|
|
|
|
|
|
|
|
|
|
// Add element as video el gets added to player
|
|
|
|
@ -185,7 +177,7 @@ QUnit.test('should allow for children that are elements', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('addChild should throw if the child does not exist', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
|
comp.addChild('non-existent-child');
|
|
|
|
@ -195,8 +187,8 @@ QUnit.test('addChild should throw if the child does not exist', function(assert)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('addChild with instance should allow getting child correctly', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp2 = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const comp2 = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
comp2.name = function() {
|
|
|
|
|
return 'foo';
|
|
|
|
@ -210,7 +202,7 @@ QUnit.test('addChild with instance should allow getting child correctly', functi
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add a child component with title case name', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
const child = comp.addChild('Component');
|
|
|
|
|
|
|
|
|
@ -224,7 +216,7 @@ QUnit.test('should add a child component with title case name', function(assert)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should init child components from options', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {
|
|
|
|
|
const comp = new Component(this.player, {
|
|
|
|
|
children: {
|
|
|
|
|
component: {}
|
|
|
|
|
}
|
|
|
|
@ -237,7 +229,7 @@ QUnit.test('should init child components from options', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should init child components from simple children array', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {
|
|
|
|
|
const comp = new Component(this.player, {
|
|
|
|
|
children: [
|
|
|
|
|
'component',
|
|
|
|
|
'component',
|
|
|
|
@ -252,7 +244,7 @@ QUnit.test('should init child components from simple children array', function(a
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should init child components from children array of objects', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {
|
|
|
|
|
const comp = new Component(this.player, {
|
|
|
|
|
children: [
|
|
|
|
|
{ name: 'component' },
|
|
|
|
|
{ name: 'component' },
|
|
|
|
@ -278,7 +270,7 @@ QUnit.test('should do a deep merge of child options', function(assert) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const comp = new Component(getFakePlayer(), {
|
|
|
|
|
const comp = new Component(this.player, {
|
|
|
|
|
example: {
|
|
|
|
|
childOne: { foo: 'baz', abc: '123' },
|
|
|
|
|
childThree: false,
|
|
|
|
@ -338,7 +330,7 @@ QUnit.test('should allows setting child options at the parent options level', fu
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
parent = new Component(getFakePlayer(), options);
|
|
|
|
|
parent = new Component(this.player, options);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
assert.ok(false, 'Child with `false` option was initialized');
|
|
|
|
|
}
|
|
|
|
@ -362,7 +354,7 @@ QUnit.test('should allows setting child options at the parent options level', fu
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
parent = new Component(getFakePlayer(), options);
|
|
|
|
|
parent = new Component(this.player, options);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
assert.ok(false, 'Child with `false` option was initialized');
|
|
|
|
|
}
|
|
|
|
@ -372,7 +364,7 @@ QUnit.test('should allows setting child options at the parent options level', fu
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should dispose of component and children', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
// Add a child
|
|
|
|
|
const child = comp.addChild('Component');
|
|
|
|
@ -413,7 +405,7 @@ QUnit.test('should dispose of component and children', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add and remove event listeners to element', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
// No need to make this async because we're triggering events inline.
|
|
|
|
|
// We're going to trigger the event after removing the listener,
|
|
|
|
@ -434,7 +426,7 @@ QUnit.test('should add and remove event listeners to element', function(assert)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should trigger a listener once using one()', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
assert.expect(1);
|
|
|
|
|
|
|
|
|
@ -450,7 +442,7 @@ QUnit.test('should trigger a listener once using one()', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should be possible to pass data when you trigger an event', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
const data1 = 'Data1';
|
|
|
|
|
const data2 = {txt: 'Data2'};
|
|
|
|
|
|
|
|
|
@ -470,7 +462,7 @@ QUnit.test('should be possible to pass data when you trigger an event', function
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add listeners to other components and remove them', function(assert) {
|
|
|
|
|
const player = getFakePlayer();
|
|
|
|
|
const player = this.player;
|
|
|
|
|
const comp1 = new Component(player);
|
|
|
|
|
const comp2 = new Component(player);
|
|
|
|
|
let listenerFired = 0;
|
|
|
|
@ -503,7 +495,7 @@ QUnit.test('should add listeners to other components and remove them', function(
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add listeners to other components and remove when them other component is disposed', function(assert) {
|
|
|
|
|
const player = getFakePlayer();
|
|
|
|
|
const player = this.player;
|
|
|
|
|
const comp1 = new Component(player);
|
|
|
|
|
const comp2 = new Component(player);
|
|
|
|
|
|
|
|
|
@ -521,7 +513,7 @@ QUnit.test('should add listeners to other components and remove when them other
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add listeners to other components that are fired once', function(assert) {
|
|
|
|
|
const player = getFakePlayer();
|
|
|
|
|
const player = this.player;
|
|
|
|
|
const comp1 = new Component(player);
|
|
|
|
|
const comp2 = new Component(player);
|
|
|
|
|
let listenerFired = 0;
|
|
|
|
@ -542,7 +534,7 @@ QUnit.test('should add listeners to other components that are fired once', funct
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add listeners to other element and remove them', function(assert) {
|
|
|
|
|
const player = getFakePlayer();
|
|
|
|
|
const player = this.player;
|
|
|
|
|
const comp1 = new Component(player);
|
|
|
|
|
const el = document.createElement('div');
|
|
|
|
|
let listenerFired = 0;
|
|
|
|
@ -583,7 +575,7 @@ QUnit.test('should add listeners to other element and remove them', function(ass
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add listeners to other components that are fired once', function(assert) {
|
|
|
|
|
const player = getFakePlayer();
|
|
|
|
|
const player = this.player;
|
|
|
|
|
const comp1 = new Component(player);
|
|
|
|
|
const el = document.createElement('div');
|
|
|
|
|
let listenerFired = 0;
|
|
|
|
@ -607,7 +599,7 @@ QUnit.test('should trigger a listener when ready', function(assert) {
|
|
|
|
|
let methodListenerFired;
|
|
|
|
|
let syncListenerFired;
|
|
|
|
|
|
|
|
|
|
const comp = new Component(getFakePlayer(), {}, function() {
|
|
|
|
|
const comp = new Component(this.player, {}, function() {
|
|
|
|
|
initListenerFired = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -647,7 +639,7 @@ QUnit.test('should trigger a listener when ready', function(assert) {
|
|
|
|
|
QUnit.test('should not retrigger a listener when the listener calls triggerReady', function(assert) {
|
|
|
|
|
let timesCalled = 0;
|
|
|
|
|
let selfTriggered = false;
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
const readyListener = function() {
|
|
|
|
|
timesCalled++;
|
|
|
|
@ -671,7 +663,7 @@ QUnit.test('should not retrigger a listener when the listener calls triggerReady
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should add and remove a CSS class', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
comp.addClass('test-class');
|
|
|
|
|
assert.ok(comp.el().className.indexOf('test-class') !== -1);
|
|
|
|
@ -686,7 +678,7 @@ QUnit.test('should add and remove a CSS class', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should show and hide an element', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
comp.hide();
|
|
|
|
|
assert.ok(comp.hasClass('vjs-hidden') === true);
|
|
|
|
@ -702,7 +694,7 @@ QUnit.test('dimension() should treat NaN and null as zero', function(assert) {
|
|
|
|
|
const width = 300;
|
|
|
|
|
const height = 150;
|
|
|
|
|
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
// set component dimension
|
|
|
|
|
|
|
|
|
|
comp.dimensions(width, height);
|
|
|
|
@ -729,7 +721,7 @@ QUnit.test('dimension() should treat NaN and null as zero', function(assert) {
|
|
|
|
|
|
|
|
|
|
QUnit.test('should change the width and height of a component', function(assert) {
|
|
|
|
|
const container = document.createElement('div');
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
const el = comp.el();
|
|
|
|
|
const fixture = document.getElementById('qunit-fixture');
|
|
|
|
|
|
|
|
|
@ -761,7 +753,7 @@ QUnit.test('should change the width and height of a component', function(assert)
|
|
|
|
|
|
|
|
|
|
QUnit.test('should get the computed dimensions', function(assert) {
|
|
|
|
|
const container = document.createElement('div');
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
const el = comp.el();
|
|
|
|
|
const fixture = document.getElementById('qunit-fixture');
|
|
|
|
|
|
|
|
|
@ -802,7 +794,7 @@ QUnit.test('should use a defined content el for appending children', function(as
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const comp = new CompWithContent(getFakePlayer());
|
|
|
|
|
const comp = new CompWithContent(this.player);
|
|
|
|
|
const child = comp.addChild('component');
|
|
|
|
|
|
|
|
|
|
assert.ok(comp.children().length === 1);
|
|
|
|
@ -823,7 +815,7 @@ QUnit.test('should use a defined content el for appending children', function(as
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should emit a tap event', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let singleTouch = {};
|
|
|
|
|
const origTouch = browser.TOUCH_ENABLED;
|
|
|
|
|
|
|
|
|
@ -882,7 +874,7 @@ QUnit.test('should emit a tap event', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should provide timeout methods that automatically get cleared on component disposal', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let timeoutsFired = 0;
|
|
|
|
|
const timeoutToClear = comp.setTimeout(function() {
|
|
|
|
|
timeoutsFired++;
|
|
|
|
@ -918,7 +910,7 @@ QUnit.test('should provide timeout methods that automatically get cleared on com
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should provide interval methods that automatically get cleared on component disposal', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
let intervalsFired = 0;
|
|
|
|
|
|
|
|
|
@ -953,7 +945,7 @@ QUnit.test('should provide interval methods that automatically get cleared on co
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should provide a requestAnimationFrame method that is cleared on disposal', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const oldRAF = window.requestAnimationFrame;
|
|
|
|
|
const oldCAF = window.cancelAnimationFrame;
|
|
|
|
|
|
|
|
|
@ -989,7 +981,7 @@ QUnit.test('should provide a requestAnimationFrame method that is cleared on dis
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should provide a requestNamedAnimationFrame method that is cleared on disposal', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const oldRAF = window.requestAnimationFrame;
|
|
|
|
|
const oldCAF = window.cancelAnimationFrame;
|
|
|
|
|
|
|
|
|
@ -1025,7 +1017,7 @@ QUnit.test('should provide a requestNamedAnimationFrame method that is cleared o
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestAnimationFrame falls back to timers if rAF not supported', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const oldRAF = window.requestAnimationFrame;
|
|
|
|
|
const oldCAF = window.cancelAnimationFrame;
|
|
|
|
|
|
|
|
|
@ -1053,7 +1045,7 @@ QUnit.test('requestAnimationFrame falls back to timers if rAF not supported', fu
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('setTimeout should remove dispose handler on trigger', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
|
|
|
|
|
comp.setTimeout(() => {}, 1);
|
|
|
|
|
|
|
|
|
@ -1067,7 +1059,7 @@ QUnit.test('setTimeout should remove dispose handler on trigger', function(asser
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestNamedAnimationFrame should remove dispose handler on trigger', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const oldRAF = window.requestAnimationFrame;
|
|
|
|
|
const oldCAF = window.cancelAnimationFrame;
|
|
|
|
|
|
|
|
|
@ -1098,7 +1090,7 @@ QUnit.test('requestNamedAnimationFrame should remove dispose handler on trigger'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestAnimationFrame should remove dispose handler on trigger', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const oldRAF = window.requestAnimationFrame;
|
|
|
|
|
const oldCAF = window.cancelAnimationFrame;
|
|
|
|
|
|
|
|
|
@ -1127,7 +1119,7 @@ QUnit.test('requestAnimationFrame should remove dispose handler on trigger', fun
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('setTimeout should be canceled on dispose', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let called = false;
|
|
|
|
|
let clearId;
|
|
|
|
|
const setId = comp.setTimeout(() => {
|
|
|
|
@ -1154,7 +1146,7 @@ QUnit.test('setTimeout should be canceled on dispose', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestAnimationFrame should be canceled on dispose', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let called = false;
|
|
|
|
|
let clearId;
|
|
|
|
|
const setId = comp.requestAnimationFrame(() => {
|
|
|
|
@ -1181,7 +1173,7 @@ QUnit.test('requestAnimationFrame should be canceled on dispose', function(asser
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('setInterval should be canceled on dispose', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let called = false;
|
|
|
|
|
let clearId;
|
|
|
|
|
const setId = comp.setInterval(() => {
|
|
|
|
@ -1208,7 +1200,7 @@ QUnit.test('setInterval should be canceled on dispose', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestNamedAnimationFrame should be canceled on dispose', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
let called = false;
|
|
|
|
|
let clearName;
|
|
|
|
|
const setName = comp.requestNamedAnimationFrame('testing', () => {
|
|
|
|
@ -1237,7 +1229,7 @@ QUnit.test('requestNamedAnimationFrame should be canceled on dispose', function(
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('requestNamedAnimationFrame should only allow one raf of a specific name at a time', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const calls = {
|
|
|
|
|
one: 0,
|
|
|
|
|
two: 0,
|
|
|
|
@ -1324,7 +1316,7 @@ QUnit.test('requestNamedAnimationFrame should only allow one raf of a specific n
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('$ and $$ functions', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer());
|
|
|
|
|
const comp = new Component(this.player);
|
|
|
|
|
const contentEl = document.createElement('div');
|
|
|
|
|
const children = [
|
|
|
|
|
document.createElement('div'),
|
|
|
|
@ -1341,7 +1333,7 @@ QUnit.test('$ and $$ functions', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should use the stateful mixin', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {});
|
|
|
|
|
const comp = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
assert.ok(Obj.isPlain(comp.state), '`state` is a plain object');
|
|
|
|
|
assert.strictEqual(Object.prototype.toString.call(comp.setState), '[object Function]', '`setState` is a function');
|
|
|
|
@ -1353,9 +1345,9 @@ QUnit.test('should use the stateful mixin', function(assert) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('should remove child when the child moves to the other parent', function(assert) {
|
|
|
|
|
const parentComponent1 = new Component(getFakePlayer(), {});
|
|
|
|
|
const parentComponent2 = new Component(getFakePlayer(), {});
|
|
|
|
|
const childComponent = new Component(getFakePlayer(), {});
|
|
|
|
|
const parentComponent1 = new Component(this.player, {});
|
|
|
|
|
const parentComponent2 = new Component(this.player, {});
|
|
|
|
|
const childComponent = new Component(this.player, {});
|
|
|
|
|
|
|
|
|
|
parentComponent1.addChild(childComponent);
|
|
|
|
|
|
|
|
|
@ -1379,10 +1371,10 @@ QUnit.test('should remove child when the child moves to the other parent', funct
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('getDescendant should work as expected', function(assert) {
|
|
|
|
|
const comp = new Component(getFakePlayer(), {name: 'component'});
|
|
|
|
|
const descendant1 = new Component(getFakePlayer(), {name: 'descendant1'});
|
|
|
|
|
const descendant2 = new Component(getFakePlayer(), {name: 'descendant2'});
|
|
|
|
|
const descendant3 = new Component(getFakePlayer(), {name: 'descendant3'});
|
|
|
|
|
const comp = new Component(this.player, {name: 'component'});
|
|
|
|
|
const descendant1 = new Component(this.player, {name: 'descendant1'});
|
|
|
|
|
const descendant2 = new Component(this.player, {name: 'descendant2'});
|
|
|
|
|
const descendant3 = new Component(this.player, {name: 'descendant3'});
|
|
|
|
|
|
|
|
|
|
comp.addChild(descendant1);
|
|
|
|
|
descendant1.addChild(descendant2);
|
|
|
|
|