feat: init
This commit is contained in:
20
test/controller/api.test.ts
Normal file
20
test/controller/api.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createApp, close, createHttpRequest } from '@midwayjs/mock';
|
||||
import { Framework } from '@midwayjs/koa';
|
||||
|
||||
describe('test/controller/home.test.ts', () => {
|
||||
|
||||
it('should POST /api/get_user', async () => {
|
||||
// create app
|
||||
const app = await createApp<Framework>();
|
||||
|
||||
// make request
|
||||
const result = await createHttpRequest(app).get('/api/get_user').query({ uid: 123 });
|
||||
|
||||
// use expect by jest
|
||||
expect(result.status).toBe(200);
|
||||
expect(result.body.message).toBe('OK');
|
||||
|
||||
// close app
|
||||
await close(app);
|
||||
});
|
||||
});
|
||||
21
test/controller/home.test.ts
Normal file
21
test/controller/home.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createApp, close, createHttpRequest } from '@midwayjs/mock';
|
||||
import { Framework } from '@midwayjs/koa';
|
||||
|
||||
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!');
|
||||
|
||||
// close app
|
||||
await close(app);
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user