import {api, DateRegex, DatetimeRegex} from "./restful"; import {Resp} from "@util/Resp"; import {models} from "@core-models/Models"; const globalAny: any = global; export const acs_module_test = () => { let module_id1, module_id2: number; beforeAll(async (done) => { globalAny.user_id = 'administrator'; await globalAny.svr.init_data_models(models); done(); }, 30000); test('获取模块树', async () => { let result = await api('/api/acs.module.get_tree', { }); expect(result.code).toBe(Resp.OK.code); expect(result.data).toBeDefined(); }); test('添加功能模块1', async () => { let result = await api('/api/acs.module.add', { tag: 'test1', name: '测试1级' }); expect(result.code).toBe(Resp.OK.code); expect(result.data).toBeDefined(); expect(result.data.id).toBeDefined(); module_id1 = result.data.id; }); test('添加功能模块2', async () => { let result = await api('/api/acs.module.add', { pid: module_id1, tag: 'test2', name: '测试2级' }); expect(result.code).toBe(Resp.OK.code); expect(result.data).toBeDefined(); expect(result.data.id).toBeDefined(); module_id2 = result.data.id; }); test('修改功能模块2', async () => { let result = await api('/api/acs.module.modify', { id: module_id2, name: '测试2级_new', memo: 'memo' }); expect(result.code).toBe(Resp.OK.code); }); test('获取模块树', async () => { let result = await api('/api/acs.module.get_tree', { }); expect(result.code).toBe(Resp.OK.code); expect(result.data).toBeDefined(); console.log(result.data.tree); expect(result.data.tree).toBeDefined(); expect(result.data.tree).toContainEqual({ id: module_id1, name: '测试1级', tag: 'test1', memo: '', children: [ { id: module_id2, name: '测试2级_new', tag: 'test2', memo: 'memo', children: [] } ] }) }); test('删除功能模块2', async () => { let result = await api('/api/acs.module.remove', { id: module_id2 }); expect(result.code).toBe(Resp.OK.code); }); test('获取模块树', async () => { let result = await api('/api/acs.module.get_tree', { }); expect(result.code).toBe(Resp.OK.code); expect(result.data).toBeDefined(); console.log(result.data.tree); expect(result.data.tree).toBeDefined(); expect(result.data.tree).toContainEqual({ id: module_id1, name: '测试1级', tag: 'test1', memo: '', children: [] }) }); }