test: add test cases for page setting atom (#2736)

This commit is contained in:
Himself65 2023-06-09 02:00:09 +08:00 committed by GitHub
parent b383ce36cd
commit 1971749449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();