38 lines
1.7 KiB
JavaScript
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: '\u042d\u043a\u0440\u0430\u043d 1', audio: '0', mode: '1', return_code: '2' }]), true);
|
|
assert.equal(d.byClient(16).name, '\u042d\u043a\u0440\u0430\u043d 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);
|
|
});
|