test(server): migrate to node internal test (#2000)

This commit is contained in:
Himself65
2023-04-18 00:07:03 -05:00
committed by GitHub
parent ea9861bfa0
commit 18223c22ef
13 changed files with 108 additions and 487 deletions
+1 -1
View File
@@ -17,4 +17,4 @@ const app = await NestFactory.create<NestExpressApplication>(AppModule, {
bodyParser: true,
});
await app.listen(process.env.PORT ?? 3000);
await app.listen(process.env.PORT ?? 3010);
@@ -35,6 +35,15 @@ export class Workspace implements workspaces {
export class WorkspaceResolver {
constructor(private readonly prisma: PrismaService) {}
// debug only query should be removed
@Query(() => [Workspace], {
name: 'workspaces',
description: 'Get all workspaces',
})
async workspaces() {
return this.prisma.workspaces.findMany();
}
@Query(() => Workspace, {
name: 'workspace',
description: 'Get workspace by id',
@@ -1,10 +1,15 @@
import { Test } from '@nestjs/testing';
import test from 'ava';
import { equal, ok } from 'node:assert';
import { beforeEach, test } from 'node:test';
import { Config, ConfigModule } from '..';
import { Test } from '@nestjs/testing';
import { Config, ConfigModule } from '../config';
import { getDefaultAFFiNEConfig } from '../config/default';
globalThis.AFFiNE = getDefaultAFFiNEConfig();
let config: Config;
test.beforeEach(async () => {
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [ConfigModule.forRoot()],
}).compile();
@@ -12,8 +17,8 @@ test.beforeEach(async () => {
});
test('should be able to get config', t => {
t.assert(typeof config.host === 'string');
t.is(config.env, 'test');
ok(typeof config.host === 'string');
equal(config.env, 'test');
});
test('should be able to override config', async t => {
@@ -26,5 +31,5 @@ test('should be able to override config', async t => {
}).compile();
const config = module.get(Config);
t.is(config.host, 'testing');
ok(config.host, 'testing');
});