GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add some test cases · terwer/lowcode-engine@3e6cfa0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/designer
    • src/document/node
      • node-children.ts
    • tests/document/node
      • node-children.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/designer/src/document/node/node-children.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/document/node/node-children.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export class NodeChildren {
161161
}
162162
}
163163
const { document } = node;
164+
/* istanbul ignore next */
164165
if (globalContext.has('editor')) {
165166
globalContext.get('editor').emit('node.remove', { node, index: i });
166167
}
@@ -197,6 +198,7 @@ export class NodeChildren {
197198
const i = children.indexOf(node);
198199

199200
if (node.parent) {
201+
/* istanbul ignore next */
200202
globalContext.has('editor') &&
201203
globalContext.get('editor').emit('node.remove.topLevel', {
202204
node,
@@ -229,6 +231,7 @@ export class NodeChildren {
229231
node,
230232
});
231233
this.emitter.emit('insert', node);
234+
/* istanbul ignore next */
232235
if (globalContext.has('editor')) {
233236
globalContext.get('editor').emit('node.add', { node });
234237
}
Collapse file

‎packages/designer/tests/document/node/node-children.test.ts‎

Copy file name to clipboardExpand all lines: packages/designer/tests/document/node/node-children.test.ts
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,42 @@ describe('NodeChildren 方法测试', () => {
4848
expect(children.export().length).toBe(2);
4949
});
5050

51+
it('export - Leaf', () => {
52+
const firstBtn = doc.getNode('node_k1ow3cbn')!;
53+
firstBtn.parent!.insertAfter({ componentName: 'Leaf', children: 'haha' });
54+
const { children } = firstBtn.parent!;
55+
56+
expect(children.export().length).toBe(3);
57+
expect(children.export()[2]).toBe('haha');
58+
});
59+
60+
it('import', () => {
61+
const firstBtn = doc.getNode('node_k1ow3cbn')!;
62+
const { children } = firstBtn.parent!;
63+
64+
children.import(children.export());
65+
66+
expect(children.export().length).toBe(2);
67+
});
68+
69+
it('delete', () => {
70+
const firstBtn = doc.getNode('node_k1ow3cbn')!;
71+
const leafNode = doc.createNode({ componentName: 'Leaf', children: 'haha' });
72+
firstBtn.parent!.insertAfter(leafNode);
73+
const { children } = firstBtn.parent!;
74+
75+
children.delete(leafNode);
76+
expect(children.export().length).toBe(2);
77+
});
78+
79+
it('delete - 插入已有的节点', () => {
80+
const firstBtn = doc.getNode('node_k1ow3cbn')!;
81+
firstBtn.parent!.insertBefore(firstBtn, firstBtn);
82+
const { children } = firstBtn.parent!;
83+
84+
expect(children.export().length).toBe(2);
85+
});
86+
5187
it('purge / for of', () => {
5288
const firstBtn = doc.getNode('node_k1ow3cbn')!;
5389
const { children } = firstBtn.parent!;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.