diff options
| author | dan <dan.abramov@gmail.com> | 2024-08-06 00:30:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-06 00:30:58 +0100 |
| commit | 5bf7f3769d005e7e606e4b10327eb7467f59f0aa (patch) | |
| tree | 1e1e2d1bb011b25a9153f39d8ba5f2281b0e1105 /src/state/persisted/__tests__/index.test.ts | |
| parent | 74b0318d89b5ec4746cd4861f8573ea24c6ccea1 (diff) | |
| download | voidsky-5bf7f3769d005e7e606e4b10327eb7467f59f0aa.tar.zst | |
[Persisted] Fork web and native, make it synchronous on the web (#4872)
* Delete logic for legacy storage * Delete superfluous tests At this point these tests aren't testing anything useful, let's just get rid of them. * Inline store.ts methods into persisted/index.ts * Fork persisted/index.ts into index.web.ts * Remove non-essential code and comments from both forks * Remove async/await from web fork of persisted/index.ts * Remove unused return * Enforce that forked types match
Diffstat (limited to 'src/state/persisted/__tests__/index.test.ts')
| -rw-r--r-- | src/state/persisted/__tests__/index.test.ts | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/state/persisted/__tests__/index.test.ts b/src/state/persisted/__tests__/index.test.ts deleted file mode 100644 index 90c5e0e4e..000000000 --- a/src/state/persisted/__tests__/index.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {jest, expect, test, afterEach} from '@jest/globals' -import AsyncStorage from '@react-native-async-storage/async-storage' - -import {defaults} from '#/state/persisted/schema' -import {migrate} from '#/state/persisted/legacy' -import * as store from '#/state/persisted/store' -import * as persisted from '#/state/persisted' - -const write = jest.mocked(store.write) -const read = jest.mocked(store.read) - -jest.mock('#/logger') -jest.mock('#/state/persisted/legacy', () => ({ - migrate: jest.fn(), -})) -jest.mock('#/state/persisted/store', () => ({ - write: jest.fn(), - read: jest.fn(), -})) - -afterEach(() => { - jest.useFakeTimers() - jest.clearAllMocks() - AsyncStorage.clear() -}) - -test('init: fresh install, no migration', async () => { - await persisted.init() - - expect(migrate).toHaveBeenCalledTimes(1) - expect(read).toHaveBeenCalledTimes(1) - expect(write).toHaveBeenCalledWith(defaults) - - // default value - expect(persisted.get('colorMode')).toBe('system') -}) - -test('init: fresh install, migration ran', async () => { - read.mockResolvedValueOnce(defaults) - - await persisted.init() - - expect(migrate).toHaveBeenCalledTimes(1) - expect(read).toHaveBeenCalledTimes(1) - expect(write).not.toHaveBeenCalled() - - // default value - expect(persisted.get('colorMode')).toBe('system') -}) |
