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 — fix(prop): emit event when delete prop · vanestone/lowcode-engine@557a462

File tree

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

‎packages/designer/src/document/node/props/prop.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/document/node/props/prop.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ export class Prop implements IProp, IPropParent {
570570
@action
571571
remove() {
572572
this.parent.delete(this);
573+
this.unset();
573574
}
574575

575576
/**
Collapse file

‎packages/designer/tests/document/node/props/prop.test.ts‎

Copy file name to clipboardExpand all lines: packages/designer/tests/document/node/props/prop.test.ts
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ const mockOwner = {
3434
},
3535
isInited: true,
3636
emitPropChange: jest.fn(),
37+
delete() {},
3738
};
3839

3940
const mockPropsInst = {
4041
owner: mockOwner,
42+
delete() {},
4143
};
44+
4245
mockPropsInst.props = mockPropsInst;
4346

4447
describe('Prop 类测试', () => {
@@ -595,6 +598,7 @@ describe('setValue with event', () => {
595598
},
596599
},
597600
emitPropChange: jest.fn(),
601+
delete() {},
598602
};
599603
mockEventBusEmit = jest.spyOn(propInstance.owner.document.designer.editor.eventBus, 'emit');
600604
mockEmitPropChange = jest.spyOn(propInstance.owner, 'emitPropChange');
@@ -665,4 +669,29 @@ describe('setValue with event', () => {
665669
propInstance.unset();
666670
expect(mockEmitChange).toHaveBeenCalledTimes(1);
667671
});
672+
673+
// remove
674+
it('should has event when remove call', () => {
675+
const oldValue = propInstance._value;
676+
677+
propInstance.remove();
678+
679+
const expectedPartialPropsInfo = expect.objectContaining({
680+
key: propInstance.key,
681+
newValue: undefined, // You can specifically test only certain keys
682+
oldValue,
683+
});
684+
685+
expect(propInstance.getValue()).toEqual(undefined);
686+
// expect(propInstance.type).toBe('unset');
687+
expect(mockEmitChange).toHaveBeenCalledWith({
688+
oldValue,
689+
newValue: undefined,
690+
});
691+
expect(mockEventBusEmit).toHaveBeenCalledWith(GlobalEvent.Node.Prop.InnerChange, expectedPartialPropsInfo);
692+
expect(mockEmitPropChange).toHaveBeenCalledWith(expectedPartialPropsInfo);
693+
694+
propInstance.remove();
695+
expect(mockEmitChange).toHaveBeenCalledTimes(1);
696+
});
668697
});

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.