diff --git a/apps/web/src/atoms/__tests__/atom.spec.ts b/apps/web/src/atoms/__tests__/atom.spec.ts index 829ad0d6d1..9099e78b53 100644 --- a/apps/web/src/atoms/__tests__/atom.spec.ts +++ b/apps/web/src/atoms/__tests__/atom.spec.ts @@ -20,8 +20,45 @@ import { createStore } from 'jotai'; import { describe, expect, test } from 'vitest'; import { WorkspaceAdapters } from '../../adapters/workspace'; +import { + pageSettingFamily, + pageSettingsAtom, + recentPageSettingsAtom, +} from '../index'; import { rootCurrentWorkspaceAtom } from '../root'; +describe('page mode atom', () => { + test('basic', () => { + const store = createStore(); + const page0SettingAtom = pageSettingFamily('page0'); + store.set(page0SettingAtom, { + mode: 'page', + }); + + expect(store.get(pageSettingsAtom)).toEqual({ + page0: { + mode: 'page', + }, + }); + + expect(store.get(recentPageSettingsAtom)).toEqual([ + { + id: 'page0', + mode: 'page', + }, + ]); + + const page1SettingAtom = pageSettingFamily('page1'); + store.set(page1SettingAtom, { + mode: 'edgeless', + }); + expect(store.get(recentPageSettingsAtom)).toEqual([ + { id: 'page1', mode: 'edgeless' }, + { id: 'page0', mode: 'page' }, + ]); + }); +}); + describe('currentWorkspace atom', () => { test('should be defined', async () => { const store = createStore();