mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
test(server): add mock mail and queue tests (#11061)
This commit is contained in:
@@ -7,6 +7,14 @@ e2e('should create test app correctly', async t => {
|
||||
t.truthy(app);
|
||||
});
|
||||
|
||||
e2e('should mock mails work', async t => {
|
||||
t.is(app.mails.count('MemberInvitation'), 0);
|
||||
});
|
||||
|
||||
e2e('should mock queue work', async t => {
|
||||
t.is(app.queue.count('notification.sendInvitation'), 0);
|
||||
});
|
||||
|
||||
e2e('should handle http request', async t => {
|
||||
const res = await app.GET('/info');
|
||||
t.is(res.status, 200);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
CacheInterceptor,
|
||||
CloudThrottlerGuard,
|
||||
GlobalExceptionFilter,
|
||||
JobQueue,
|
||||
OneMB,
|
||||
} from '../../base';
|
||||
import { SocketIoAdapter } from '../../base/websocket';
|
||||
@@ -22,6 +23,7 @@ import { Mailer } from '../../core/mail';
|
||||
import {
|
||||
createFactory,
|
||||
MockedUser,
|
||||
MockJobQueue,
|
||||
MockMailer,
|
||||
MockUser,
|
||||
MockUserInput,
|
||||
@@ -40,6 +42,7 @@ export class TestingApp extends NestApplication {
|
||||
|
||||
create = createFactory(this.get(PrismaClient, { strict: false }));
|
||||
mails = this.get(Mailer, { strict: false }) as MockMailer;
|
||||
queue = this.get(JobQueue, { strict: false }) as MockJobQueue;
|
||||
|
||||
get url() {
|
||||
const server = this.getHttpServer();
|
||||
@@ -193,6 +196,9 @@ export async function createApp(
|
||||
imports: [buildAppModule()],
|
||||
});
|
||||
|
||||
builder.overrideProvider(Mailer).useValue(new MockMailer());
|
||||
builder.overrideProvider(JobQueue).useValue(new MockJobQueue());
|
||||
|
||||
// when custom override happens
|
||||
if (tapModule) {
|
||||
tapModule(builder);
|
||||
|
||||
Reference in New Issue
Block a user