WIP
This commit is contained in:
parent
34ac200437
commit
39b0160064
136 changed files with 7129 additions and 1950 deletions
|
|
@ -4,22 +4,12 @@ import { gardenAudioConfig } from './audio/garden-audio-config';
|
|||
import { getInitialVibe, hexToRgb, VIBE_PRESETS } from './vibes';
|
||||
|
||||
const originalLocalStorage = globalThis.localStorage;
|
||||
const originalWindow = globalThis.window;
|
||||
|
||||
const setBrowserVibeState = ({
|
||||
search = '',
|
||||
storedVibeId = null,
|
||||
}: {
|
||||
search?: string;
|
||||
storedVibeId?: string | null;
|
||||
}) => {
|
||||
Object.defineProperty(globalThis, 'window', {
|
||||
configurable: true,
|
||||
value: {
|
||||
location: new URL(`https://garden.test/${search}`),
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(globalThis, 'localStorage', {
|
||||
configurable: true,
|
||||
value: {
|
||||
|
|
@ -30,38 +20,22 @@ const setBrowserVibeState = ({
|
|||
});
|
||||
};
|
||||
|
||||
describe('vibe URL selection', () => {
|
||||
describe('vibe selection', () => {
|
||||
afterEach(() => {
|
||||
Object.defineProperty(globalThis, 'window', {
|
||||
configurable: true,
|
||||
value: originalWindow,
|
||||
});
|
||||
Object.defineProperty(globalThis, 'localStorage', {
|
||||
configurable: true,
|
||||
value: originalLocalStorage,
|
||||
});
|
||||
});
|
||||
|
||||
it('uses a valid vibe id from the URL before local storage', () => {
|
||||
setBrowserVibeState({
|
||||
search: '?vibe=moon-orchid',
|
||||
storedVibeId: 'candy-rain',
|
||||
});
|
||||
|
||||
expect(getInitialVibe().id).toBe('moon-orchid');
|
||||
});
|
||||
|
||||
it('uses a valid stored vibe id when the URL does not provide one', () => {
|
||||
it('uses a valid stored vibe id', () => {
|
||||
setBrowserVibeState({ storedVibeId: 'sunlit-moss' });
|
||||
|
||||
expect(getInitialVibe().id).toBe('sunlit-moss');
|
||||
});
|
||||
|
||||
it('falls back to the default preset for an unknown URL vibe id', () => {
|
||||
setBrowserVibeState({
|
||||
search: '?vibe=unknown',
|
||||
storedVibeId: 'sunlit-moss',
|
||||
});
|
||||
it('falls back to the default preset for an unknown stored vibe id', () => {
|
||||
setBrowserVibeState({ storedVibeId: 'unknown' });
|
||||
|
||||
expect(getInitialVibe()).toBe(VIBE_PRESETS[0]);
|
||||
});
|
||||
|
|
@ -107,7 +81,6 @@ describe('vibe and audio config contract', () => {
|
|||
expect(gardenAudioConfig.colorVoices).toHaveLength(3);
|
||||
gardenAudioConfig.colorVoices.forEach((voice) => {
|
||||
expect(Number.isFinite(voice.scaleDegreeOffset)).toBe(true);
|
||||
expect(Number.isFinite(voice.octaveOffset)).toBe(true);
|
||||
expect(voice.velocityMultiplier).toBeGreaterThan(0);
|
||||
expect(Math.abs(voice.panOffset)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue