@npo/player 1.24.4 → 1.24.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npo/player",
3
- "version": "1.24.4",
3
+ "version": "1.24.5",
4
4
  "description": "NPO Player",
5
5
  "author": "Publieke Omroep <player@npo.nl>",
6
6
  "contributors": [
@@ -1,6 +1 @@
1
- import '@testing-library/jest-dom';
2
- declare global {
3
- interface Window {
4
- bitmovin: any;
5
- }
6
- }
1
+ export {};
@@ -3,6 +3,7 @@ export function showPlayNextScreenIfNeeded(overlayDuration, containerEl, proceed
3
3
  const playnextOverlay = containerEl.querySelector('.bmpui-overlay-playnext');
4
4
  if (playnextOverlay?.classList.contains('show'))
5
5
  return;
6
+ clearInterval(countdownInterval);
6
7
  playnextOverlay?.classList.add('show');
7
8
  const playNextButton = playnextOverlay?.querySelector('.ui-playNextButton');
8
9
  if (playNextButton) {
@@ -22,5 +23,6 @@ export function showPlayNextScreenIfNeeded(overlayDuration, containerEl, proceed
22
23
  }, 1000);
23
24
  }
24
25
  export function hidePlayNextScreen(containerEl) {
26
+ clearInterval(countdownInterval);
25
27
  containerEl.querySelector('.bmpui-overlay-playnext')?.classList.remove('show');
26
28
  }
@@ -1,6 +1 @@
1
- import '@testing-library/jest-dom';
2
- declare global {
3
- interface Window {
4
- bitmovin: any;
5
- }
6
- }
1
+ export {};
@@ -1,48 +1,45 @@
1
- import { showPlayNextScreenIfNeeded } from './playnextscreen';
2
- import { sendCustomMessage } from '../nativemobileuicontainer';
3
- import '@testing-library/jest-dom';
4
- jest.mock('../nativemobileuicontainer');
5
- describe('showPlayNextScreenIfNeeded', () => {
1
+ import { hidePlayNextScreen, showPlayNextScreenIfNeeded } from './playnextscreen';
2
+ describe('showPlayNextScreenIfNeeded and hidePlayNextScreen', () => {
6
3
  let containerEl;
7
- let playnextOverlay;
8
- let countdownLabel;
9
- let playNextButton;
10
4
  let proceedCallBack;
5
+ const OVERLAY_DURATION_MS = 5000;
6
+ const INTERVAL_STEP_MS = 1000;
11
7
  beforeEach(() => {
12
- ;
13
- sendCustomMessage.mockClear();
14
- playnextOverlay = document.createElement('div');
15
- playnextOverlay.classList.add('bmpui-overlay-playnext');
16
- countdownLabel = document.createElement('div');
17
- countdownLabel.classList.add('countdown');
18
- playnextOverlay.appendChild(countdownLabel);
19
- playNextButton = document.createElement('button');
20
- playNextButton.classList.add('ui-playNextButton');
21
- playnextOverlay.appendChild(playNextButton);
8
+ jest.useFakeTimers();
22
9
  containerEl = document.createElement('div');
23
- containerEl.appendChild(playnextOverlay);
10
+ containerEl.innerHTML = `
11
+ <div class="bmpui-overlay-playnext">
12
+ <button class="ui-playNextButton"></button>
13
+ </div>
14
+ `;
15
+ document.body.appendChild(containerEl);
24
16
  proceedCallBack = jest.fn();
25
17
  });
26
18
  afterEach(() => {
27
19
  jest.clearAllTimers();
20
+ containerEl.remove();
28
21
  });
29
- it('should not show overlay if it is already shown', () => {
30
- playnextOverlay.classList.add('show');
31
- showPlayNextScreenIfNeeded(10, containerEl, proceedCallBack);
32
- expect(playnextOverlay).toHaveClass('show');
33
- expect(proceedCallBack).not.toHaveBeenCalled();
22
+ it('should show the play next overlay and start the countdown', () => {
23
+ showPlayNextScreenIfNeeded(OVERLAY_DURATION_MS / INTERVAL_STEP_MS, containerEl, proceedCallBack);
24
+ const playnextOverlay = containerEl.querySelector('.bmpui-overlay-playnext');
25
+ expect(playnextOverlay?.classList.contains('show')).toBe(true);
26
+ jest.advanceTimersByTime(OVERLAY_DURATION_MS);
27
+ expect(proceedCallBack).toHaveBeenCalled();
28
+ expect(playnextOverlay?.classList.contains('show')).toBe(false);
34
29
  });
35
- it('should show overlay and start countdown', () => {
36
- jest.useFakeTimers();
37
- showPlayNextScreenIfNeeded(10, containerEl, proceedCallBack);
38
- expect(playnextOverlay).toHaveClass('show');
39
- expect(playNextButton.style.getPropertyValue('--animation-duration')).toBe('10s');
30
+ it('should clear interval when countdown reaches zero', () => {
31
+ showPlayNextScreenIfNeeded(OVERLAY_DURATION_MS / INTERVAL_STEP_MS, containerEl, proceedCallBack);
32
+ jest.advanceTimersByTime(OVERLAY_DURATION_MS);
33
+ expect(proceedCallBack).toHaveBeenCalledTimes(1);
34
+ jest.advanceTimersByTime(INTERVAL_STEP_MS);
35
+ expect(proceedCallBack).toHaveBeenCalledTimes(1);
40
36
  });
41
- it('should call proceedCallBack and hide overlay when countdown finishes', () => {
42
- jest.useFakeTimers();
43
- showPlayNextScreenIfNeeded(1, containerEl, proceedCallBack);
44
- jest.advanceTimersByTime(2000);
45
- expect(proceedCallBack).toHaveBeenCalled();
46
- expect(playnextOverlay).not.toHaveClass('show');
37
+ it('should hide the play next overlay and clear the countdown interval when hidePlayNextScreen is called', () => {
38
+ showPlayNextScreenIfNeeded(OVERLAY_DURATION_MS / INTERVAL_STEP_MS, containerEl, proceedCallBack);
39
+ hidePlayNextScreen(containerEl);
40
+ const playnextOverlay = containerEl.querySelector('.bmpui-overlay-playnext');
41
+ expect(playnextOverlay?.classList.contains('show')).toBe(false);
42
+ jest.advanceTimersByTime(INTERVAL_STEP_MS);
43
+ expect(proceedCallBack).not.toHaveBeenCalled();
47
44
  });
48
45
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npo/player",
3
- "version": "1.24.4",
3
+ "version": "1.24.5",
4
4
  "description": "NPO Player",
5
5
  "author": "Publieke Omroep <player@npo.nl>",
6
6
  "contributors": [