playable
Version:
Video player based on HTML5Video
82 lines • 3.84 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('BottomBlock', function () {
var testkit;
var mainBlock;
var eventEmitter;
beforeEach(function () {
testkit = (0, testkit_1.default)();
eventEmitter = testkit.getModule('eventEmitter');
mainBlock = testkit.getModule('mainUIBlock');
});
describe('constructor', function () {
it('should create instance ', function () {
(0, chai_1.expect)(mainBlock).to.exist;
});
});
describe('instance', function () {
it('should have method for setting playback state', function () {
(0, chai_1.expect)(mainBlock._updatePlayingState).to.exist;
var startTimeout = sinon.spy(mainBlock, '_startHideBlockTimeout');
var showTimeout = sinon.spy(mainBlock, '_showContent');
mainBlock._updatePlayingState({ nextState: constants_1.EngineState.PLAY_REQUESTED });
(0, chai_1.expect)(startTimeout.called).to.be.true;
mainBlock._updatePlayingState({ nextState: constants_1.EngineState.PAUSED });
(0, chai_1.expect)(showTimeout.called).to.be.true;
showTimeout.resetHistory();
mainBlock._updatePlayingState({ nextState: constants_1.EngineState.ENDED });
(0, chai_1.expect)(showTimeout.called).to.be.true;
showTimeout.resetHistory();
mainBlock._updatePlayingState({ nextState: constants_1.EngineState.SRC_SET });
(0, chai_1.expect)(showTimeout.called).to.be.true;
});
it('should have method for hiding controls on timeout', function () {
var timeoutSpy = sinon.spy(window, 'setTimeout');
var clearSpy = sinon.spy(window, 'clearTimeout');
mainBlock._startHideBlockTimeout();
(0, chai_1.expect)(timeoutSpy.calledWith(mainBlock._tryHideContent, 2000)).to.be.true;
mainBlock._startHideBlockTimeout();
(0, chai_1.expect)(clearSpy.called).to.be.true;
timeoutSpy.restore();
clearSpy.restore();
});
});
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(mainBlock, '_updatePlayingState');
mainBlock._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('API', function () {
it('should have method for showing whole view', function () {
(0, chai_1.expect)(mainBlock.show).to.exist;
mainBlock.show();
(0, chai_1.expect)(mainBlock.isHidden).to.be.false;
});
it('should have method for hiding whole view', function () {
(0, chai_1.expect)(mainBlock.hide).to.exist;
mainBlock.hide();
(0, chai_1.expect)(mainBlock.isHidden).to.be.true;
});
});
});
//# sourceMappingURL=main-ui-block.spec.js.map