about summary refs log tree commit diff
path: root/src/state/persisted/__tests__/schema.test.ts
blob: c78a2c27cb1be2d3a0b2f284e84e0b82845e7940 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {expect, test} from '@jest/globals'

import {transform} from '#/state/persisted/legacy'
import {defaults, schema} from '#/state/persisted/schema'
import * as fixtures from '#/state/persisted/__tests__/fixtures'

test('defaults', () => {
  expect(() => schema.parse(defaults)).not.toThrow()
})

test('transform', () => {
  const data = transform({})
  expect(() => schema.parse(data)).not.toThrow()
})

test('transform: legacy fixture', () => {
  const data = transform(fixtures.LEGACY_DATA_DUMP)
  expect(() => schema.parse(data)).not.toThrow()
  expect(data.session.currentAccount?.did).toEqual(fixtures.ALICE_DID)
  expect(data.session.accounts.length).toEqual(2)
})