mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-26 11:56:25 -08:00
27 lines
935 B
TypeScript
27 lines
935 B
TypeScript
import { beforeEach, describe, expect, it } from 'vitest';
|
|
import type { Session } from '$state/sessions';
|
|
import { ACTIVE_SESSION_KEY, MATRIX_SESSIONS_KEY } from '$state/sessions';
|
|
import { ownsActiveMediaSession } from './initMatrix';
|
|
|
|
const alice = { userId: '@alice:example.org' } as Session;
|
|
const bob = { userId: '@bob:example.org' } as Session;
|
|
|
|
describe('ownsActiveMediaSession', () => {
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
localStorage.setItem(MATRIX_SESSIONS_KEY, JSON.stringify([alice, bob]));
|
|
});
|
|
|
|
it('keeps Alice media session while logging out secondary Bob', () => {
|
|
localStorage.setItem(ACTIVE_SESSION_KEY, JSON.stringify(alice.userId));
|
|
|
|
expect(ownsActiveMediaSession(bob)).toBe(false);
|
|
});
|
|
|
|
it('clears the active account media session', () => {
|
|
localStorage.setItem(ACTIVE_SESSION_KEY, JSON.stringify(alice.userId));
|
|
|
|
expect(ownsActiveMediaSession(alice)).toBe(true);
|
|
});
|
|
});
|