about summary refs log tree commit diff
path: root/src/state/persisted/__tests__/index.test.ts
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-08-06 00:30:58 +0100
committerGitHub <noreply@github.com>2024-08-06 00:30:58 +0100
commit5bf7f3769d005e7e606e4b10327eb7467f59f0aa (patch)
tree1e1e2d1bb011b25a9153f39d8ba5f2281b0e1105 /src/state/persisted/__tests__/index.test.ts
parent74b0318d89b5ec4746cd4861f8573ea24c6ccea1 (diff)
downloadvoidsky-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.ts49
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')
-})