33 lines
867 B
TypeScript
33 lines
867 B
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
const request = require('supertest');
|
|
import { AppModule } from './../src/app.module';
|
|
|
|
describe('AppController (e2e)', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
await app.init();
|
|
});
|
|
|
|
it('/callback (POST) - missing task_id should return error in body', () => {
|
|
return request(app.getHttpServer())
|
|
.post('/callback')
|
|
.send({})
|
|
.expect(201)
|
|
.expect((res) => {
|
|
expect(res.body.code).toBe(400);
|
|
expect(res.body.message).toBe('缺少task_id');
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|