UNPKG

playable

Version:

Video player based on HTML5Video

72 lines 3.01 kB
"use strict"; 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"); var PictureInPictureMock = /** @class */ (function () { function PictureInPictureMock() { this.enterPictureInPicture = function () { }; this.exitPictureInPicture = function () { }; this.isEnabled = true; this._config = {}; } return PictureInPictureMock; }()); describe('PictureInPictureControl', function () { var testkit; var control = {}; var eventEmitter = {}; beforeEach(function () { testkit = (0, testkit_1.default)(); testkit.registerModule('pictureInPicture', PictureInPictureMock); eventEmitter = testkit.getModule('eventEmitter'); control = testkit.getModule('pictureInPictureControl'); }); describe('constructor', function () { it('should create instance ', function () { (0, chai_1.expect)(control).to.exist; (0, chai_1.expect)(control.view).to.exist; }); }); describe('ui 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.view, 'setPictureInPictureState'); control._bindEvents(); return [4 /*yield*/, eventEmitter.emitAsync(constants_1.UIEvent.PICTURE_IN_PICTURE_STATUS_CHANGE)]; case 1: _a.sent(); (0, chai_1.expect)(spy.called).to.be.true; return [2 /*return*/]; } }); }); }); }); describe('API', function () { it('should have method for showing whole view', function () { (0, chai_1.expect)(control.show).to.exist; control.show(); (0, chai_1.expect)(control.isHidden).to.be.false; }); it('should have method for hiding whole view', function () { (0, chai_1.expect)(control.hide).to.exist; control.hide(); (0, chai_1.expect)(control.isHidden).to.be.true; }); 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; }); }); }); //# sourceMappingURL=picture-in-picture.spec.js.map