-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathArgsController.test.ts
More file actions
34 lines (32 loc) · 979 Bytes
/
ArgsController.test.ts
File metadata and controls
34 lines (32 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { app } from '@eggjs/mock/bootstrap';
import { expect, test } from 'vite-plus/test';
test('should POST /api/args/request success', async () => {
app.mockCsrf();
const res = await app.httpRequest().post('/api/args/request').send({
name: 'foo',
desc: 'mock-desc 🥚🥚🥚',
});
expect(res.status).toBe(200);
// console.log(res.body);
expect(res.body).toEqual({
headerData: null,
arrayBufferDataString: '{"name":"foo","desc":"mock-desc 🥚🥚🥚"}',
});
});
test('should POST /api/args/request2 error', async () => {
app.mockCsrf();
const res = await app.httpRequest().post('/api/args/request2').send({
name: 'foo',
desc: 'mock-desc 🥚🥚🥚',
});
expect(res.status).toBe(200);
console.log(res.body);
expect(res.body).toEqual({
headerData: null,
body: {
name: 'foo',
desc: 'mock-desc 🥚🥚🥚',
},
arrayBufferDataString: '{"name":"foo","desc":"mock-desc 🥚🥚🥚"}',
});
});