Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test/unit/video.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ 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