mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 20:26:29 +00:00
34 lines
658 B
TypeScript
34 lines
658 B
TypeScript
|
/*
|
||
|
# 编写 Application 测试用例
|
||
|
|
||
|
# 执行测试
|
||
|
yarn jest examples/app/__tests__/app.test.ts
|
||
|
*/
|
||
|
import { MockServer, mockServer } from '@nocobase/test';
|
||
|
|
||
|
describe('app test', () => {
|
||
|
let app: MockServer;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
app = mockServer();
|
||
|
});
|
||
|
|
||
|
test('test1', async () => {
|
||
|
app.resource({
|
||
|
name: 'test',
|
||
|
actions: {
|
||
|
async list(ctx, next) {
|
||
|
ctx.body = 'test list';
|
||
|
await next();
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
const response = await app.agent().resource('test').list();
|
||
|
expect(response.body).toEqual({ data: 'test list' });
|
||
|
});
|
||
|
|
||
|
afterEach(async () => {
|
||
|
await app.destroy();
|
||
|
});
|
||
|
});
|