There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
test: add workspaces unit test
alt059fc7731747a
diff --git a/packages/data-center/src/workspaces/workspaces.spec.ts b/packages/data-center/src/workspaces/workspaces.spec.tsnew file mode 100644index 0000000000..859cbabfb0--- /dev/null+++ b/packages/data-center/src/workspaces/workspaces.spec.ts@@ -0,0 +1,50 @@+import { describe, test, expect } from 'vitest';+import { Workspaces } from './workspaces';+import type { WorkspacesChangeEvent } from './workspaces';++describe('workspaces observable', () => {+ const workspaces = new Workspaces();++ const scope = workspaces.createScope();++ test('add workspace', () => {+ workspaces.once('change', (event: WorkspacesChangeEvent) => {+ expect(event.added?.id).toEqual('123');+ });+ scope.add({+ id: '123',+ name: 'test',+ memberCount: 1,+ provider: '',+ });+ });++ test('list workspace', () => {+ const list = scope.list();+ expect(list.length).toEqual(1);+ expect(list[0].id).toEqual('123');+ });++ test('get workspace', () => {+ expect(scope.get('123')?.id).toEqual('123');+ });++ test('update workspace', () => {+ workspaces.once('change', (event: WorkspacesChangeEvent) => {+ expect(event.updated?.name).toEqual('demo');+ });+ scope.update('123', { name: 'demo' });+ });++ test('get workspace form other scope', () => {+ const scope1 = workspaces.createScope();+ expect(scope1.get('123')).toBeFalsy();+ });++ test('delete workspace', () => {+ workspaces.once('change', (event: WorkspacesChangeEvent) => {+ expect(event.deleted?.id).toEqual('123');+ });+ scope.remove('123');+ });+});