mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-09 04:49:50 -07:00
feat(notifications): add overlay notifications with position config (#110)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createOverlayLoadingOsdController } from './overlay-loading-osd';
|
||||
|
||||
test('overlay loading OSD shows spinner ticks and clears when stopped', () => {
|
||||
const messages: string[] = [];
|
||||
const clearedTimers: unknown[] = [];
|
||||
let tick: (() => void) | null = null;
|
||||
const controller = createOverlayLoadingOsdController({
|
||||
showOsd: (message) => {
|
||||
messages.push(message);
|
||||
},
|
||||
clearOsd: () => {
|
||||
messages.push('clear');
|
||||
},
|
||||
setInterval: (callback) => {
|
||||
tick = callback;
|
||||
return 'timer';
|
||||
},
|
||||
clearInterval: (timer) => {
|
||||
clearedTimers.push(timer);
|
||||
},
|
||||
});
|
||||
|
||||
controller.start();
|
||||
controller.start();
|
||||
|
||||
assert.deepEqual(messages, ['Overlay loading |']);
|
||||
if (!tick) {
|
||||
assert.fail('expected spinner tick callback');
|
||||
}
|
||||
const tickCallback: () => void = tick;
|
||||
tickCallback();
|
||||
tickCallback();
|
||||
|
||||
controller.stop();
|
||||
controller.stop();
|
||||
|
||||
assert.deepEqual(messages, ['Overlay loading |', 'Overlay loading /', 'Overlay loading -', 'clear']);
|
||||
assert.deepEqual(clearedTimers, ['timer']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user