22 lines
919 B
TypeScript
Raw Normal View History

import test from 'node:test';
import assert from 'node:assert/strict';
import { getLegacyIngressTopic, extractLegacyRealmFromIngressTopic, getMxIngressTopic, extractMxIngressFromTopic, getInternalTopic } from '@open-matrix/federation/topics';
test('legacy ingress roundtrip', () => {
const realm = 'flowpad-demo.tab-01';
const t = getLegacyIngressTopic(realm);
assert.ok(t.startsWith('public.ingress.'));
assert.equal(extractLegacyRealmFromIngressTopic(t), realm);
});
test('mx ingress roundtrip', () => {
const t = getMxIngressTopic('acme.com', '00');
assert.equal(t, 'acme.com.$ingress.00');
assert.deepEqual(extractMxIngressFromTopic(t), { root: 'acme.com', shard: '00' });
});
test('internal topic returns semantic path directly', () => {
const t = getInternalTopic('matrix-3', 'env/prod/root.ui.app.editor.accepts.setText');
assert.equal(t, 'env/prod/root.ui.app.editor.accepts.setText');
});