mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-23 00:11:28 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
58
src/main/runtime/jellyfin-remote-session-main-deps.test.ts
Normal file
58
src/main/runtime/jellyfin-remote-session-main-deps.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
createBuildStartJellyfinRemoteSessionMainDepsHandler,
|
||||
createBuildStopJellyfinRemoteSessionMainDepsHandler,
|
||||
} from './jellyfin-remote-session-main-deps';
|
||||
|
||||
test('start jellyfin remote session main deps builder maps callbacks', async () => {
|
||||
const calls: string[] = [];
|
||||
const session = { start: () => {}, stop: () => {}, advertiseNow: async () => true };
|
||||
const deps = createBuildStartJellyfinRemoteSessionMainDepsHandler({
|
||||
getJellyfinConfig: () => ({ serverUrl: 'http://localhost' }) as never,
|
||||
getCurrentSession: () => null,
|
||||
setCurrentSession: () => calls.push('set-session'),
|
||||
createRemoteSessionService: () => session as never,
|
||||
defaultDeviceId: 'device',
|
||||
defaultClientName: 'SubMiner',
|
||||
defaultClientVersion: '1.0',
|
||||
handlePlay: async () => {
|
||||
calls.push('play');
|
||||
},
|
||||
handlePlaystate: async () => {
|
||||
calls.push('playstate');
|
||||
},
|
||||
handleGeneralCommand: async () => {
|
||||
calls.push('general');
|
||||
},
|
||||
logInfo: (message) => calls.push(`info:${message}`),
|
||||
logWarn: (message) => calls.push(`warn:${message}`),
|
||||
})();
|
||||
|
||||
assert.deepEqual(deps.getJellyfinConfig(), { serverUrl: 'http://localhost' });
|
||||
assert.equal(deps.defaultDeviceId, 'device');
|
||||
assert.equal(deps.defaultClientName, 'SubMiner');
|
||||
assert.equal(deps.defaultClientVersion, '1.0');
|
||||
assert.equal(deps.createRemoteSessionService({} as never), session);
|
||||
await deps.handlePlay({});
|
||||
await deps.handlePlaystate({});
|
||||
await deps.handleGeneralCommand({});
|
||||
deps.logInfo('connected');
|
||||
deps.logWarn('missing');
|
||||
assert.deepEqual(calls, ['play', 'playstate', 'general', 'info:connected', 'warn:missing']);
|
||||
});
|
||||
|
||||
test('stop jellyfin remote session main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const session = { start: () => {}, stop: () => {}, advertiseNow: async () => true };
|
||||
const deps = createBuildStopJellyfinRemoteSessionMainDepsHandler({
|
||||
getCurrentSession: () => session as never,
|
||||
setCurrentSession: () => calls.push('set-null'),
|
||||
clearActivePlayback: () => calls.push('clear'),
|
||||
})();
|
||||
|
||||
assert.equal(deps.getCurrentSession(), session);
|
||||
deps.setCurrentSession(null);
|
||||
deps.clearActivePlayback();
|
||||
assert.deepEqual(calls, ['set-null', 'clear']);
|
||||
});
|
||||
Reference in New Issue
Block a user