Files
client/test/stream-directory.test.mjs
T
omar 7287fdb63e
ci / linux-x64 (push) Failing after 1m26s
ci / linux-arm64-cross (push) Failing after 2m20s
TeamsPeach desktop client: Electron UI, Rust core bridge, TS6 stream viewer, CI
2026-10-24 03:31:54 +03:00

38 lines
1.7 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { StreamDirectory } from '../app/renderer/js/stream/directory.js';
test('notifystreaminfo with id registers a stream; return_code-only replies are ignored', () => {
const d = new StreamDirectory();
assert.equal(d.handle('notifystreaminfo', [{ return_code: '1' }]), false);
assert.equal(d.handle('notifystreaminfo', [{ id: 'c4', clid: '16', name: 'Экран 1', audio: '0', mode: '1', return_code: '2' }]), true);
assert.equal(d.byClient(16).name, 'Экран 1');
assert.equal(d.get('c4').fields.audio, '0');
});
test('updates merge fields, stop removes, prune drops absent clients', () => {
const d = new StreamDirectory();
d.handle('notifystreamstarted', [{ id: 'a', clid: '5', name: 'one' }, { id: 'b', clid: '6', name: 'two' }]);
d.handle('notifystreamupdated', [{ id: 'a', name: 'renamed' }]);
assert.equal(d.get('a').name, 'renamed');
assert.equal(d.get('a').clientId, 5);
assert.equal(d.handle('notifystreamupdated', [{ id: 'zzz', name: 'x' }]), false, 'updates never create');
d.handle('notifystreamstopped', [{ id: 'a' }]);
assert.equal(d.get('a'), null);
assert.equal(d.prune(new Set([1, 2])), true);
assert.equal(d.streams.size, 0);
});
test('stop by clid only (requeststreaminfo error) removes that client stream', () => {
const d = new StreamDirectory();
d.handle('notifystreaminfo', [{ id: 'a', clid: '5' }]);
assert.equal(d.handle('notifystreamstopped', [{ clid: '5' }]), true);
assert.equal(d.byClient(5), null);
});
test('SFU notification is remembered', () => {
const d = new StreamDirectory();
assert.equal(d.handle('notifysfuaccessinfo', [{}]), true);
assert.equal(d.sfuSeen, true);
});