mirror of https://github.com/certd/certd
27 lines
670 B
TypeScript
Executable File
27 lines
670 B
TypeScript
Executable File
import { createApp, close, createHttpRequest } from '@midwayjs/mock';
|
|
import { Framework } from '@midwayjs/koa';
|
|
import * as assert from 'assert';
|
|
|
|
describe('test/controller/home.test.ts', () => {
|
|
|
|
it('should GET /', async () => {
|
|
// create app
|
|
const app = await createApp<Framework>();
|
|
|
|
// make request
|
|
const result = await createHttpRequest(app).get('/');
|
|
|
|
// use expect by jest
|
|
expect(result.status).toBe(200);
|
|
expect(result.text).toBe('Hello Midwayjs!');
|
|
|
|
// or use assert
|
|
assert.deepStrictEqual(result.status, 200);
|
|
assert.deepStrictEqual(result.text, 'Hello Midwayjs!');
|
|
|
|
// close app
|
|
await close(app);
|
|
});
|
|
|
|
});
|