Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
harisha-swaminathan committed Aug 23, 2024
1 parent b6418a9 commit e774014
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QUnit from 'qunit';
import sinon from 'sinon';
import videojs from 'video.js';
import window from 'global/window';
import * as plug from '../src/plugin';
import {
default as plugin,
hasSession,
Expand Down Expand Up @@ -517,6 +518,46 @@ QUnit.test('handleEncryptedEvent uses predefined init data', function(assert) {
});
});

QUnit.test('handleEncryptedEvent called explicitly on replay or seekback after `ended` if browser is Firefox ', function(assert) {
const done = assert.async();

this.clock = sinon.useFakeTimers();

videojs.browser = {
IS_FIREFOX: true
};
this.player.eme();

this.player.trigger('ready');
this.player.trigger('play');

plug.handleEncryptedEvent = sinon.spy();

this.clock.tick(1);
this.player.trigger('ended');
this.clock.tick(1);
this.player.trigger('play');
assert.ok(plug.handleEncryptedEvent.calledOnce, 'HandleEncryptedEvent called if play fires after ended');
plug.handleEncryptedEvent.resetHistory();

this.player.trigger('ended');
this.player.trigger('seek');
assert.ok(plug.handleEncryptedEvent.calledOnce, 'HandleEncryptedEvent called if seek fires after ended');
plug.handleEncryptedEvent.resetHistory();

this.player.trigger('ended');
this.player.trigger('seek');

this.player.eme.sessions.push({});

this.player.trigger('play');
assert.ok(plug.handleEncryptedEvent.calledOnce, 'HandleEncryptedEvent only called once if seek and play both fire after ended');
plug.handleEncryptedEvent.resetHistory();

sinon.restore();
done();
});

QUnit.test('handleMsNeedKeyEvent uses predefined init data', function(assert) {
const options = {
keySystems: {
Expand Down

0 comments on commit e774014

Please sign in to comment.