UNPKG

playable

Version:

Video player based on HTML5Video

112 lines 5.06 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")); describe('Title', function () { var testkit; // let eventEmitter; var title; beforeEach(function () { testkit = (0, testkit_1.default)(); title = testkit.getModule('title'); // eventEmitter = testkit.getModule('eventEmitter'); }); describe('constructor', function () { it('should create instance ', function () { (0, chai_1.expect)(title).to.exist; (0, chai_1.expect)(title.view).to.exist; }); }); describe('instance', function () { it('should have method for showing title', function () { var viewShowSpy = sinon.spy(title.view, 'show'); title.show(); (0, chai_1.expect)(viewShowSpy.called).to.be.true; (0, chai_1.expect)(title.isHidden).to.be.false; viewShowSpy.restore(); }); it('should have method for hiding title', function () { var viewHideSpy = sinon.spy(title.view, 'hide'); title.hide(); (0, chai_1.expect)(viewHideSpy.called).to.be.true; (0, chai_1.expect)(title.isHidden).to.be.true; viewHideSpy.restore(); }); it('should have method for getting view node', function () { var getTitleViewNodeSpy = sinon.spy(title.view, 'getElement'); var titleViewNode = title.getElement(); (0, chai_1.expect)(getTitleViewNodeSpy.called).to.be.true; (0, chai_1.expect)(titleViewNode).to.equal(title.view.getElement()); getTitleViewNodeSpy.restore(); }); }); describe('API', function () { describe('setTitle method', function () { var titleViewSetTitleSpy; var titleViewShowSpy; var titleViewHideSpy; beforeEach(function () { titleViewSetTitleSpy = sinon.spy(title.view, 'setTitle'); titleViewShowSpy = sinon.spy(title.view, 'show'); titleViewHideSpy = sinon.spy(title.view, 'hide'); }); afterEach(function () { titleViewSetTitleSpy.restore(); titleViewShowSpy.restore(); titleViewHideSpy.restore(); }); it('should exists', function () { (0, chai_1.expect)(title.setTitle).to.exist; }); it('should set NOT EMPTY title', function () { var TITLE_TEXT = 'TITLE'; title.setTitle(TITLE_TEXT); (0, chai_1.expect)(titleViewSetTitleSpy.calledWith(TITLE_TEXT)).to.be.true; //@ts-ignore (0, chai_1.expect)(title.view._$rootElement.innerHTML).to.equal(TITLE_TEXT); (0, chai_1.expect)(titleViewShowSpy.called).to.be.true; }); it('should set EMPTY title', function () { title.setTitle(''); (0, chai_1.expect)(titleViewSetTitleSpy.calledWith('')).to.be.true; // TODO: should html be cleared if setTitle called with empty value? (0, chai_1.expect)(titleViewHideSpy.called).to.be.true; }); }); describe('setTitleClickCallback method', function () { var setViewDisplayAsLinkSpy; beforeEach(function () { setViewDisplayAsLinkSpy = sinon.spy(title.view, 'setDisplayAsLink'); }); afterEach(function () { setViewDisplayAsLinkSpy.restore(); }); it('should exists', function () { (0, chai_1.expect)(title.setTitleClickCallback).to.exist; }); it('should set NOT EMPTY callback', function () { var clickCallback = sinon.spy(); title.setTitleClickCallback(clickCallback); //@ts-ignore title.view._$rootElement.dispatchEvent(new Event('click')); (0, chai_1.expect)(setViewDisplayAsLinkSpy.calledWith(true)).to.be.true; (0, chai_1.expect)(clickCallback.called).to.be.true; }); it('should set EMPTY callback', function () { var clickCallback = sinon.spy(); title.setTitleClickCallback(clickCallback); //@ts-ignore title.view._$rootElement.dispatchEvent(new Event('click')); title.setTitleClickCallback(); //@ts-ignore title.view._$rootElement.dispatchEvent(new Event('click')); (0, chai_1.expect)(setViewDisplayAsLinkSpy.lastCall.calledWith(false)).to.be.true; (0, chai_1.expect)(clickCallback.calledOnce).to.be.true; }); }); }); }); //# sourceMappingURL=title.spec.js.map