mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-13 09:08:16 +03:00
test: add test cases for page setting atom (#2736)
This commit is contained in:
parent
b383ce36cd
commit
1971749449
@ -20,8 +20,45 @@ import { createStore } from 'jotai';
|
|||||||
import { describe, expect, test } from 'vitest';
|
import { describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
import { WorkspaceAdapters } from '../../adapters/workspace';
|
import { WorkspaceAdapters } from '../../adapters/workspace';
|
||||||
|
import {
|
||||||
|
pageSettingFamily,
|
||||||
|
pageSettingsAtom,
|
||||||
|
recentPageSettingsAtom,
|
||||||
|
} from '../index';
|
||||||
import { rootCurrentWorkspaceAtom } from '../root';
|
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', () => {
|
describe('currentWorkspace atom', () => {
|
||||||
test('should be defined', async () => {
|
test('should be defined', async () => {
|
||||||
const store = createStore();
|
const store = createStore();
|
||||||
|
Loading…
Reference in New Issue
Block a user