-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathSimpleController.test.ts
More file actions
23 lines (20 loc) · 825 Bytes
/
SimpleController.test.ts
File metadata and controls
23 lines (20 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { app } from '@eggjs/mock/bootstrap';
import { expect, test } from 'vite-plus/test';
test('should GET /api/headers with headers', async () => {
await app.httpRequest().get('/api/headers').set('X-Custom', 'custom').expect(200).expect({
message: `hello custom`,
});
});
test('should GET /api/hello/:name', async () => {
await app.httpRequest().get('/api/hello/world').expect(200).expect({
message: `hello world`,
});
});
test('should GET /api/foo', async () => {
const res = await app.httpRequest().get('/api/foo').expect(200);
console.log(res.body.data.version, res.body.data.description);
expect(res.body.message).toBe('hello, bar: hello, world!');
expect(res.body.data).toBeDefined();
expect(res.body.data.name).toBe('egg');
expect(res.body.data.version).toMatch(/^\d+\.\d+\.\d+/);
});