playable
Version:
Video player based on HTML5Video
64 lines • 2.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
require("jsdom-global/register");
var chai_1 = require("chai");
var sinon = (0, tslib_1.__importStar)(require("sinon"));
var testkit_1 = (0, tslib_1.__importDefault)(require("../../../../testkit"));
var constants_1 = require("../../../../constants");
describe('PlayControl', function () {
var testkit;
var control;
var eventEmitter;
beforeEach(function () {
testkit = (0, testkit_1.default)();
eventEmitter = testkit.getModule('eventEmitter');
control = testkit.getModule('playControl');
});
describe('constructor', function () {
it('should create instance ', function () {
(0, chai_1.expect)(control).to.exist;
(0, chai_1.expect)(control.view).to.exist;
});
});
describe('API', function () {
it('should have method for destroying', function () {
var spy = sinon.spy(control, '_unbindEvents');
(0, chai_1.expect)(control.destroy).to.exist;
control.destroy();
(0, chai_1.expect)(spy.called).to.be.true;
});
});
describe('video events listeners', function () {
it('should call callback on playback state change', function () {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
var spy;
return (0, tslib_1.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
spy = sinon.spy(control, '_updatePlayingState');
control._bindEvents();
return [4 /*yield*/, eventEmitter.emitAsync(constants_1.VideoEvent.STATE_CHANGED, {})];
case 1:
_a.sent();
(0, chai_1.expect)(spy.called).to.be.true;
return [2 /*return*/];
}
});
});
});
});
describe('internal methods', function () {
it('should change playback state', function () {
var playSpy = sinon.stub(control._engine, 'play');
var pauseSpy = sinon.stub(control._engine, 'pause');
control._playVideo();
(0, chai_1.expect)(playSpy.called).to.be.true;
control._pauseVideo();
(0, chai_1.expect)(pauseSpy.called).to.be.true;
control._engine.play.restore();
control._engine.pause.restore();
});
});
});
//# sourceMappingURL=play.spec.js.map