mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 17:39:55 +08:00
refactor: use yarn (#1619)
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
import type { GetBlob, PutBlob } from '../ipc/types/blob';
|
||||
import type {
|
||||
GetDocumentParameter,
|
||||
GetDocumentResponse,
|
||||
YDocumentUpdate,
|
||||
} from '../ipc/types/document';
|
||||
import type { CreateUser, GetUserParameters, User } from '../ipc/types/user';
|
||||
import type {
|
||||
CreateWorkspace,
|
||||
CreateWorkspaceResult,
|
||||
GetWorkspace,
|
||||
GetWorkspaceResult,
|
||||
GetWorkspaces,
|
||||
GetWorkspacesResult,
|
||||
} from '../ipc/types/workspace';
|
||||
|
||||
export const updateYDocument = async (parameters: YDocumentUpdate) =>
|
||||
await true;
|
||||
|
||||
export const getYDocument = async (
|
||||
parameters: GetDocumentParameter
|
||||
): Promise<GetDocumentResponse> =>
|
||||
await {
|
||||
updates: [],
|
||||
};
|
||||
|
||||
export const createWorkspace = async (
|
||||
parameters: CreateWorkspace
|
||||
): Promise<CreateWorkspaceResult> => await { id: 'xxx', name: 'xxx' };
|
||||
|
||||
export const getWorkspaces = async (
|
||||
parameters: GetWorkspaces
|
||||
): Promise<GetWorkspacesResult> =>
|
||||
await {
|
||||
workspaces: [],
|
||||
};
|
||||
|
||||
export const getWorkspace = async (
|
||||
parameters: GetWorkspace
|
||||
): Promise<GetWorkspaceResult> =>
|
||||
await {
|
||||
workspace: {
|
||||
created_at: 0,
|
||||
id: '',
|
||||
member_count: 1,
|
||||
public: true,
|
||||
type: 0,
|
||||
},
|
||||
};
|
||||
|
||||
export const putBlob = async (parameters: PutBlob): Promise<string> =>
|
||||
await 'path/xxx';
|
||||
|
||||
export const getBlob = async (parameters: GetBlob): Promise<number[]> =>
|
||||
await [];
|
||||
|
||||
/**
|
||||
* This will create a private workspace too.
|
||||
* @returns
|
||||
*/
|
||||
export const createUser = async (parameters: CreateUser): Promise<User> =>
|
||||
await {
|
||||
created_at: 0,
|
||||
id: '1',
|
||||
email: 'xxx@xxx.xxx',
|
||||
name: 'xxx',
|
||||
};
|
||||
|
||||
export const getUser = async (parameters: GetUserParameters): Promise<User> =>
|
||||
await {
|
||||
created_at: 0,
|
||||
id: '1',
|
||||
email: 'xxx@xxx.xxx',
|
||||
name: 'xxx',
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
import 'fake-indexeddb/auto';
|
||||
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { MessageCenter } from '../../../message';
|
||||
import { WorkspaceUnitCollection } from '../../../workspace-unit-collection';
|
||||
import { TauriIPCProvider } from '..';
|
||||
import * as ipcMethods from './mock-apis';
|
||||
|
||||
describe('tauri-ipc provider', async () => {
|
||||
const workspaceMetaCollection = new WorkspaceUnitCollection();
|
||||
const provider = new TauriIPCProvider({
|
||||
workspaces: workspaceMetaCollection.createScope(),
|
||||
messageCenter: new MessageCenter(),
|
||||
});
|
||||
provider.init(ipcMethods);
|
||||
|
||||
const workspaceName = 'workspace-test';
|
||||
let workspaceId: string | undefined;
|
||||
|
||||
test('create workspace', async () => {
|
||||
const workspaceUnit = await provider.createWorkspace({
|
||||
name: workspaceName,
|
||||
});
|
||||
workspaceId = workspaceUnit?.id;
|
||||
|
||||
expect(workspaceMetaCollection.workspaces.length).toEqual(1);
|
||||
expect(workspaceMetaCollection.workspaces[0].name).toEqual(workspaceName);
|
||||
});
|
||||
|
||||
test('workspace list', async () => {
|
||||
const workspacesMetaCollection1 = new WorkspaceUnitCollection();
|
||||
const provider1 = new TauriIPCProvider({
|
||||
workspaces: workspacesMetaCollection1.createScope(),
|
||||
messageCenter: new MessageCenter(),
|
||||
});
|
||||
provider1.init(ipcMethods);
|
||||
|
||||
await provider1.getUserInfo();
|
||||
await provider1.loadWorkspaces();
|
||||
expect(workspacesMetaCollection1.workspaces.length).toEqual(0);
|
||||
await provider1.createWorkspace({
|
||||
name: workspaceName,
|
||||
});
|
||||
expect(workspacesMetaCollection1.workspaces[0].name).toEqual(workspaceName);
|
||||
expect(workspacesMetaCollection1.workspaces[0].id).toEqual(workspaceId);
|
||||
});
|
||||
|
||||
test('update workspace', async () => {
|
||||
await provider.updateWorkspaceMeta(workspaceId!, {
|
||||
name: '1111',
|
||||
});
|
||||
expect(workspaceMetaCollection.workspaces[0].name).toEqual('1111');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user