Skip to content

Commit

Permalink
fix: fix editor.remove and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed May 14, 2024
1 parent 89c470f commit 1427d6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Editor {
remove() {
const controls = [...this.controls.getArray()];
controls.forEach((control) => {
control.removeControl(control);
this.removeControl(control);
});
if (this.toolbar) {
this.toolbar.destroy();
Expand Down
14 changes: 14 additions & 0 deletions src/editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ describe('editor', () => {
expect(cad.editor).toBe();
expect(cad.getActive()).toBe(false);
});

test('is removed', () => {
editor.addControl(cad);
cad.activate();
expect(cad.getActive()).toBe(true);
expect(editor.controls.getArray()[0]).toBe(cad);
expect(editor.activeControls.getArray()[0]).toBe(cad);
editor.remove();
expect(editor.controls.getLength()).toBe(0);
expect(editor.activeControls.getLength()).toBe(0);
expect(cad.map).toBe();
expect(cad.editor).toBe();
expect(cad.getActive()).toBe(false);
});
});

0 comments on commit 1427d6e

Please sign in to comment.