@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
|
@@ -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,48 +1,45 @@
|
|
|
1
|
-
import { showPlayNextScreenIfNeeded } from './playnextscreen';
|
|
2
|
-
|
|
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.
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
expect(playnextOverlay
|
|
33
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
expect(
|
|
39
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
expect(
|
|
46
|
-
|
|
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
|
});
|