acs_module.test.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {api, DateRegex, DatetimeRegex} from "./restful";
  2. import {Resp} from "@util/Resp";
  3. import {models} from "@core-models/Models";
  4. const globalAny: any = global;
  5. export const acs_module_test = () => {
  6. let module_id1, module_id2: number;
  7. beforeAll(async (done) => {
  8. globalAny.user_id = 'administrator';
  9. await globalAny.svr.init_data_models(models);
  10. done();
  11. }, 30000);
  12. test('获取模块树', async () => {
  13. let result = await api('/api/acs.module.get_tree', {
  14. });
  15. expect(result.code).toBe(Resp.OK.code);
  16. expect(result.data).toBeDefined();
  17. });
  18. test('添加功能模块1', async () => {
  19. let result = await api('/api/acs.module.add', {
  20. tag: 'test1',
  21. name: '测试1级'
  22. });
  23. expect(result.code).toBe(Resp.OK.code);
  24. expect(result.data).toBeDefined();
  25. expect(result.data.id).toBeDefined();
  26. module_id1 = result.data.id;
  27. });
  28. test('添加功能模块2', async () => {
  29. let result = await api('/api/acs.module.add', {
  30. pid: module_id1,
  31. tag: 'test2',
  32. name: '测试2级'
  33. });
  34. expect(result.code).toBe(Resp.OK.code);
  35. expect(result.data).toBeDefined();
  36. expect(result.data.id).toBeDefined();
  37. module_id2 = result.data.id;
  38. });
  39. test('修改功能模块2', async () => {
  40. let result = await api('/api/acs.module.modify', {
  41. id: module_id2,
  42. name: '测试2级_new',
  43. memo: 'memo'
  44. });
  45. expect(result.code).toBe(Resp.OK.code);
  46. });
  47. test('获取模块树', async () => {
  48. let result = await api('/api/acs.module.get_tree', {
  49. });
  50. expect(result.code).toBe(Resp.OK.code);
  51. expect(result.data).toBeDefined();
  52. console.log(result.data.tree);
  53. expect(result.data.tree).toBeDefined();
  54. expect(result.data.tree).toContainEqual({
  55. id: module_id1,
  56. name: '测试1级',
  57. tag: 'test1',
  58. memo: '',
  59. children: [
  60. {
  61. id: module_id2,
  62. name: '测试2级_new',
  63. tag: 'test2',
  64. memo: 'memo',
  65. children: []
  66. }
  67. ]
  68. })
  69. });
  70. test('删除功能模块2', async () => {
  71. let result = await api('/api/acs.module.remove', {
  72. id: module_id2
  73. });
  74. expect(result.code).toBe(Resp.OK.code);
  75. });
  76. test('获取模块树', async () => {
  77. let result = await api('/api/acs.module.get_tree', {
  78. });
  79. expect(result.code).toBe(Resp.OK.code);
  80. expect(result.data).toBeDefined();
  81. console.log(result.data.tree);
  82. expect(result.data.tree).toBeDefined();
  83. expect(result.data.tree).toContainEqual({
  84. id: module_id1,
  85. name: '测试1级',
  86. tag: 'test1',
  87. memo: '',
  88. children: []
  89. })
  90. });
  91. }