mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 03:55:10 +00:00
28b73d7143
* feat: add examples * fix: tsconfig-paths/register * feat: more examples * fix: test errors * feat: update examples * docs: example list * fix: updates * feat: example for test case * feat: api client * fix: updates * feat: tree structures * fix: adjacency-list
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();
|
|
});
|
|
});
|