Files
Psychotoxical-psysonic/src/lib/share/shareServerOriginLabel.test.ts
T
Psychotoxical 92635381ea refactor(share): split share cluster into lib/share + features/share
a11y-branch hold lifted. Pure share machinery (no @/features runtime imports) →
lib/share: shareLink, shareSearch, shareServerOriginLabel, copyEntityShareLink
(+tests). The two orchestrators that runtime-import offline/playback/orbit →
new features/share: applySharePaste, enqueueShareSearchPayload (+test); doc-only
barrel, consumers use deep paths. No low-layer consumes the orchestrators, so no
seam is needed — pure move, tests pass unmodified. Drains utils/share.

Only import lines changed in the PasteClipboardHandler consumer (logic untouched).
2026-06-30 22:21:57 +02:00

47 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { encodeSharePayload } from '@/lib/share/shareLink';
import { parseShareSearchText } from '@/lib/share/shareSearch';
import { shareServerOriginLabel } from '@/lib/share/shareServerOriginLabel';
const home = {
id: 'home',
name: 'Home NAS',
url: 'https://music.home.example',
username: 'u1',
password: 'p1',
};
const office = {
id: 'office',
name: 'Office',
url: 'https://music.office.example',
username: 'u2',
password: 'p2',
};
describe('shareServerOriginLabel', () => {
it('returns null when share targets the active server', () => {
const match = parseShareSearchText(
encodeSharePayload({ srv: home.url, k: 'track', id: 't-1' }),
);
expect(shareServerOriginLabel(match, [home, office], 'home')).toBeNull();
});
it('returns the saved server display name when share is from another saved server', () => {
const match = parseShareSearchText(
encodeSharePayload({ srv: office.url, k: 'track', id: 't-1' }),
);
expect(shareServerOriginLabel(match, [home, office], 'home')).toBe('Office');
});
it('returns null when the share server is not in saved profiles', () => {
const match = parseShareSearchText(
encodeSharePayload({ srv: 'https://unknown.example', k: 'track', id: 't-1' }),
);
expect(shareServerOriginLabel(match, [home], 'home')).toBeNull();
});
it('returns null for unsupported share payloads', () => {
expect(shareServerOriginLabel({ type: 'unsupported' }, [home], 'home')).toBeNull();
});
});