nocobase/examples/app/__tests__/app.test.ts
chenos 28b73d7143
feat: add examples (#718)
* 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
2022-08-16 14:41:29 +08:00

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();
});
});