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

implement lifecycle hooks and trigger pre/post setup hooks #3639

Merged
merged 10 commits into from
Nov 4, 2016
20 changes: 20 additions & 0 deletions test/unit/video.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,23 @@ QUnit.test('beforesetup returns dont break videojs options', function(assert) {
assert.ok(player.options_, 'beforesetup should not destory options');
assert.equal(player.options_.techOrder, vjsOptions.techOrder, 'options set by user should exist');
});

QUnit.test('beforesetup options override videojs options', function(assert) {
const vjsOptions = {techOrder: ['techFaker'], autoplay: false};
const fixture = document.getElementById('qunit-fixture');

fixture.innerHTML += '<video id="test_vid_id"><source type="video/mp4"></video>';

const vid = document.getElementById('test_vid_id');

videojs.hook('beforesetup', function(options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add another hook that say adds fluid: true option?

assert.equal(options.autoplay, false, 'false was passed to us');
return {autoplay: true};
});

const player = videojs(vid, vjsOptions);

assert.ok(player.options_, 'beforesetup should not destory options');
assert.equal(player.options_.techOrder, vjsOptions.techOrder, 'options set by user should exist');
assert.equal(player.options_.autoplay, true, 'autoplay should be set to true now');
});