AFFiNE/packages/backend/server/tests/utils/feature.ts
2024-12-09 18:51:54 +09:00

28 lines
743 B
TypeScript

import { Injectable } from '@nestjs/common';
import { PrismaClient, WorkspaceMemberStatus } from '@prisma/client';
import { Permission } from '../../src/core/permission';
import { UserType } from '../../src/core/user/types';
@Injectable()
export class WorkspaceResolverMock {
constructor(private readonly prisma: PrismaClient) {}
async createWorkspace(user: UserType, _init: null) {
const workspace = await this.prisma.workspace.create({
data: {
public: false,
permissions: {
create: {
type: Permission.Owner,
userId: user.id,
accepted: true,
status: WorkspaceMemberStatus.Accepted,
},
},
},
});
return workspace;
}
}