Skip to content

Commit

Permalink
test: warning, if the element is not in the DOM (#4723)
Browse files Browse the repository at this point in the history
Add test to #4698
  • Loading branch information
odisei369 authored and gkatsev committed Nov 7, 2017
1 parent acc641a commit c213737
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/unit/video.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c213737

Please sign in to comment.