import { MockHelper, TestingPlayerAPI } from '../helper/MockHelper'; import { UIContainer } from '../../src/ts/components/uicontainer'; import { UIInstanceManager } from '../../src/ts/uimanager'; import { PlayerUtils } from '../../src/ts/playerutils'; let playerMock: TestingPlayerAPI; let uiInstanceManagerMock: UIInstanceManager; describe('UIContainer', () => { let uiContainer: UIContainer; beforeEach(() => { playerMock = MockHelper.getPlayerMock(); uiInstanceManagerMock = MockHelper.getUiInstanceManagerMock(); }); describe('release', () => { beforeEach(() => { uiContainer = new UIContainer({ hideDelay: -1, // With an hideDelay of -1 the uiHideTimeout and userInteractionEvents never will be initialized components: [], }); }); describe('with configured hide delay of -1', () => { /* no exception expected */ it('works without calling configure', () => { uiContainer.release(); }); /* no exception expected */ it('works with calling configure', () => { uiContainer.configure(playerMock, uiInstanceManagerMock); uiContainer.release(); }); }); }); describe('automatically hiding', () => { describe('hidePlayerStateExceptions', () => { it('UI does not hide itself when switching into prevented state', () => { uiContainer = new UIContainer({ components: [], hidePlayerStateExceptions: [PlayerUtils.PlayerState.Prepared], }); uiContainer.configure(playerMock, uiInstanceManagerMock); let uiHideTimeoutSpy: any = jest.spyOn((uiContainer as any).uiHideTimeout, 'start'); playerMock.eventEmitter.fireSourceLoadedEvent(); expect(uiHideTimeoutSpy).not.toHaveBeenCalled(); }); }); }); });