mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
test(server): make server testing utils (#5544)
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
/// <reference types="../src/global.d.ts" />
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TestingModule } from '@nestjs/testing';
|
||||
import ava, { type TestFn } from 'ava';
|
||||
|
||||
import { CacheModule } from '../src/cache';
|
||||
import { ConfigModule } from '../src/config';
|
||||
import { SessionModule, SessionService } from '../src/session';
|
||||
import { createTestingModule } from './utils';
|
||||
|
||||
const test = ava as TestFn<{
|
||||
session: SessionService;
|
||||
app: TestingModule;
|
||||
module: TestingModule;
|
||||
}>;
|
||||
|
||||
test.beforeEach(async t => {
|
||||
const module = await Test.createTestingModule({
|
||||
const module = await createTestingModule({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
redis: {
|
||||
@@ -23,14 +24,14 @@ test.beforeEach(async t => {
|
||||
CacheModule,
|
||||
SessionModule,
|
||||
],
|
||||
}).compile();
|
||||
});
|
||||
const session = module.get(SessionService);
|
||||
t.context.app = module;
|
||||
t.context.module = module;
|
||||
t.context.session = session;
|
||||
});
|
||||
|
||||
test.afterEach.always(async t => {
|
||||
await t.context.app.close();
|
||||
await t.context.module.close();
|
||||
});
|
||||
|
||||
test('should be able to set session', async t => {
|
||||
|
||||
Reference in New Issue
Block a user