diff --git a/src/test/webapp/unit/module/secondary/FakeStorage.fixture.ts b/src/test/webapp/unit/module/secondary/FakeStorage.fixture.ts new file mode 100644 index 00000000000..df04fa88f59 --- /dev/null +++ b/src/test/webapp/unit/module/secondary/FakeStorage.fixture.ts @@ -0,0 +1,13 @@ +export const fakeStorage = (): Storage => { + let store: { [key: string]: string } = {}; + return { + getItem: (key: string) => store[key], + setItem: (key: string, value: string) => (store[key] = value), + removeItem: (key: string) => delete store[key], + clear: () => (store = {}), + get length() { + return Object.keys(store).length; + }, + key: (index: number) => Object.keys(store)[index], + }; +}; diff --git a/src/test/webapp/unit/module/secondary/LocalStorageModuleParametersRepository.spec.ts b/src/test/webapp/unit/module/secondary/LocalStorageModuleParametersRepository.spec.ts index 7f7bdba96c6..c061c10dcf2 100644 --- a/src/test/webapp/unit/module/secondary/LocalStorageModuleParametersRepository.spec.ts +++ b/src/test/webapp/unit/module/secondary/LocalStorageModuleParametersRepository.spec.ts @@ -1,20 +1,7 @@ import { ModuleParameterType } from '@/module/domain/ModuleParameters'; import { LocalStorageModuleParametersRepository } from '@/module/secondary/LocalStorageModuleParametersRepository'; import { describe, expect, it } from 'vitest'; - -const fakeStorage = (): Storage => { - let store: { [key: string]: string } = {}; - return { - getItem: (key: string) => store[key], - setItem: (key: string, value: string) => (store[key] = value), - removeItem: (key: string) => delete store[key], - clear: () => (store = {}), - get length() { - return Object.keys(store).length; - }, - key: (index: number) => Object.keys(store)[index], - }; -}; +import { fakeStorage } from './FakeStorage.fixture'; const STORAGE_KEY_MODULE_PARAMETERS_SUFFIX = '_moduleParameters'; const STORAGE_KEY_CURRENT_FOLDER_PATH = 'currentFolderPath'; diff --git a/src/test/webapp/unit/module/secondary/LocalWindowThemeRepository.spec.ts b/src/test/webapp/unit/module/secondary/LocalWindowThemeRepository.spec.ts index 83f582e1d83..5829c7d1871 100644 --- a/src/test/webapp/unit/module/secondary/LocalWindowThemeRepository.spec.ts +++ b/src/test/webapp/unit/module/secondary/LocalWindowThemeRepository.spec.ts @@ -1,20 +1,7 @@ import { LocalWindowThemeRepository } from '@/module/secondary/LocalWindowThemeRepository'; import { describe, expect, it } from 'vitest'; import { stubWindow } from '../primary/GlobalWindow.fixture'; - -const fakeStorage = (): Storage => { - let store: { [key: string]: string } = {}; - return { - getItem: (key: string) => store[key], - setItem: (key: string, value: string) => (store[key] = value), - removeItem: (key: string) => delete store[key], - clear: () => (store = {}), - get length() { - return Object.keys(store).length; - }, - key: (index: number) => Object.keys(store)[index], - }; -}; +import { fakeStorage } from './FakeStorage.fixture'; describe('LocalWindowThemeRepository', () => { it('should return light theme if no user theme preference stored in localStorage', () => {