123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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: []
- })
- });
- }
|