26 lines
735 B
TypeScript
26 lines
735 B
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { getPrefs, setPrefs } from '../prefs';
|
|
|
|
describe('prefs', () => {
|
|
beforeEach(() => {
|
|
const store: Record<string, string> = {};
|
|
vi.stubGlobal('localStorage', {
|
|
getItem(key: string) {
|
|
return store[key] ?? null;
|
|
},
|
|
setItem(key: string, value: string) {
|
|
store[key] = value;
|
|
},
|
|
});
|
|
});
|
|
|
|
it('returns defaults when localStorage empty', () => {
|
|
expect(getPrefs()).toEqual({ storyOpenMode: 'auto', actionDetailMode: 'inline' });
|
|
});
|
|
|
|
it('round-trips updated prefs', () => {
|
|
setPrefs({ storyOpenMode: 'manual', actionDetailMode: 'hover' });
|
|
expect(getPrefs().storyOpenMode).toBe('manual');
|
|
});
|
|
});
|