123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import {api} from "./restful";
- import {Resp} from "@util/Resp";
- import {models} from "@core-models/Models";
- const globalAny: any = global;
- export const acs_domain_test = () => {
- let domain_id1, domain_id2: number;
- beforeAll(async (done) => {
- globalAny.user_id = 'admin';
- await globalAny.svr.init_data_models(models);
- done();
- }, 30000);
- test('获取组织机构树', async () => {
- let result = await api('/api/acs.domain.get_tree', {
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.tree).toBeDefined();
- });
- test('获取组织机构树', async () => {
- let result = await api('/api/acs.domain.get_tree', {
- pid: 100
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.tree).toBeDefined();
- });
- test('添加组织机构', async () => {
- let result = await api('/api/acs.domain.add', {
- pid: 100,
- name: 'domain',
- tag: 'tag',
- memo: 'memo'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.id).toBeDefined();
- domain_id1 = result.data.id;
- });
- test('添加组织机构1', async () => {
- let result = await api('/api/acs.domain.add', {
- pid: domain_id1,
- name: 'domain2',
- tag: 'tag2',
- memo: 'memo2'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.id).toBeDefined();
- domain_id2 = result.data.id;
- });
- test('修改组织机构2', async () => {
- let result = await api('/api/acs.domain.modify', {
- id: domain_id2,
- name: 'domain2new',
- tag: 'tag2new',
- memo: 'memo2new'
- });
- expect(result.code).toBe(Resp.OK.code);
- });
- test('获取组织机构树', async () => {
- let result = await api('/api/acs.domain.get_tree', {
- pid: 100
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.tree).toBeDefined();
- expect(result.data.tree[0].children).toContainEqual({
- id: domain_id1,
- name: 'domain',
- tag: 'tag',
- memo: 'memo',
- children: [
- {
- id: domain_id2,
- name: 'domain2new',
- tag: 'tag2new',
- memo: 'memo2new',
- children: []
- }
- ]
- })
- });
- test('删除组织机构 ', async () => {
- let result = await api('/api/acs.domain.remove', {
- id: domain_id1
- });
- expect(result.code).toBe(Resp.KeyStillReferenced.code);
- });
- test('删除组织机构 ', async () => {
- let result = await api('/api/acs.domain.remove', {
- id: domain_id2
- });
- expect(result.code).toBe(Resp.OK.code);
- });
- test('获取组织机构树', async () => {
- let result = await api('/api/acs.domain.get_tree', {
- pid: 100
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.tree).toBeDefined();
- console.log(result.data.tree);
- expect(result.data.tree[0].children).toContainEqual({
- id: domain_id1,
- name: 'domain',
- tag: 'tag',
- memo: 'memo',
- children: []
- })
- });
- }
|