1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-24 08:42:25 +02:00

test: warning, if the element is not in the DOM (#4723)

Add test to #4698
This commit is contained in:
Ilya Piatrenka 2017-11-07 23:44:16 +03:00 committed by Gary Katsevman
parent acc641a8a2
commit c213737f7a

View File

@ -53,6 +53,38 @@ QUnit.test('should return a video player instance', function(assert) {
player2.dispose();
});
QUnit.test('should log if the supplied element is not included in the DOM',
function(assert) {
const origWarnLog = log.warn;
const fixture = document.getElementById('qunit-fixture');
const warnLogs = [];
log.warn = (args) => {
warnLogs.push(args);
};
const vid = document.createElement('video');
fixture.appendChild(vid);
const player = videojs(vid);
assert.ok(player, 'created player from tag');
assert.equal(warnLogs.length, 0, 'no warn logs');
const vid2 = document.createElement('video');
const player2 = videojs(vid2);
assert.ok(player2, 'created player from tag');
assert.equal(warnLogs.length, 1, 'logged a warning');
assert.equal(warnLogs[0],
'The element supplied is not included in the DOM',
'logged the right message');
log.warn = origWarnLog;
player.dispose();
player2.dispose();
});
QUnit.test('should log about already initalized players if options already passed',
function(assert) {
const origWarnLog = log.warn;