1
0

Updates
All checks were successful
Test / test (push) Successful in 9m33s

This commit is contained in:
Aiden
2026-06-11 05:48:19 +10:00
parent a470d4bdc7
commit fbdb733f13
13 changed files with 310 additions and 15 deletions

View File

@@ -0,0 +1,44 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
DEFAULT_MENU_AUTO_HIDE_DELAY_MS,
PLAYING_VIDEO_MENU_AUTO_HIDE_DELAY_MS,
getVideoAwareAutoHideDelayMs,
isVideoActivelyPlaying
} from '../vr180player/utils/control-panel-timing.js';
test('isVideoActivelyPlaying only returns true for non-paused, non-ended video state', () => {
assert.equal(isVideoActivelyPlaying({ paused: false, ended: false }), true);
assert.equal(isVideoActivelyPlaying({ paused: true, ended: false }), false);
assert.equal(isVideoActivelyPlaying({ paused: false, ended: true }), false);
assert.equal(isVideoActivelyPlaying(undefined), false);
});
test('getVideoAwareAutoHideDelayMs uses the shorter delay while video is playing', () => {
assert.equal(
getVideoAwareAutoHideDelayMs({ paused: false, ended: false }),
PLAYING_VIDEO_MENU_AUTO_HIDE_DELAY_MS
);
assert.equal(
getVideoAwareAutoHideDelayMs({ paused: true, ended: false }),
DEFAULT_MENU_AUTO_HIDE_DELAY_MS
);
});
test('getVideoAwareAutoHideDelayMs accepts custom delay values for other control surfaces', () => {
assert.equal(
getVideoAwareAutoHideDelayMs(
{ paused: false, ended: false },
{ idleDelayMs: 3000, playingDelayMs: 1500 }
),
1500
);
assert.equal(
getVideoAwareAutoHideDelayMs(
{ paused: true, ended: false },
{ idleDelayMs: 3000, playingDelayMs: 1500 }
),
3000
);
});

67
tests/icons.test.mjs Normal file
View File

@@ -0,0 +1,67 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { drawLucideIcon } from '../vr180player/dom/icons.js';
function createCanvasContextRecorder() {
const calls = [];
return {
calls,
beginPath() {
calls.push(['beginPath']);
},
closePath() {
calls.push(['closePath']);
},
lineTo(x, y) {
calls.push(['lineTo', x, y]);
},
moveTo(x, y) {
calls.push(['moveTo', x, y]);
},
restore() {
calls.push(['restore']);
},
save() {
calls.push(['save']);
},
scale(x, y) {
calls.push(['scale', x, y]);
},
stroke() {
calls.push(['stroke']);
},
translate(x, y) {
calls.push(['translate', x, y]);
},
set lineCap(value) {
calls.push(['lineCap', value]);
},
set lineJoin(value) {
calls.push(['lineJoin', value]);
},
set lineWidth(value) {
calls.push(['lineWidth', value]);
},
set strokeStyle(value) {
calls.push(['strokeStyle', value]);
}
};
}
test('drawLucideIcon renders space-separated polygon points for the play icon', () => {
const ctx = createCanvasContextRecorder();
drawLucideIcon(ctx, 'play', 0, 0, 24);
assert.deepEqual(
ctx.calls.filter(([name]) => name === 'moveTo' || name === 'lineTo' || name === 'closePath'),
[
['moveTo', 6, 3],
['lineTo', 20, 12],
['lineTo', 6, 21],
['lineTo', 6, 3],
['closePath']
]
);
});

View File

@@ -119,6 +119,52 @@ test('MediaController toggles loop playback state', () => {
assert.equal(video.loop, false);
});
test('MediaController restarts looping video just before the ended boundary', () => {
const { controller, video } = createController({
video: createVideo({
currentTime: 119.9,
duration: 120,
loop: true,
paused: false
})
});
controller.handleTimeUpdate();
assert.equal(video.currentTime, 0);
assert.equal(video.playCount, 1);
});
test('MediaController leaves non-looping or paused video alone near the ended boundary', () => {
const { controller: nonLoopingController, video: nonLoopingVideo } = createController({
video: createVideo({
currentTime: 119.9,
duration: 120,
loop: false,
paused: false
})
});
nonLoopingController.handleTimeUpdate();
assert.equal(nonLoopingVideo.currentTime, 119.9);
assert.equal(nonLoopingVideo.playCount, 0);
const { controller: pausedController, video: pausedVideo } = createController({
video: createVideo({
currentTime: 119.9,
duration: 120,
loop: true,
paused: true
})
});
pausedController.handleTimeUpdate();
assert.equal(pausedVideo.currentTime, 119.9);
assert.equal(pausedVideo.playCount, 0);
});
test('MediaController resets video and play button to poster state', () => {
const playButton = { classList: createClassList(), disabled: true };
playButton.classList.add('hidden');