Skip to content

Commit

Permalink
fix(annotations): Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Nov 5, 2020
1 parent 82da743 commit b6371a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ class BaseViewer extends EventEmitter {
if (this.annotator && this.areNewAnnotationsEnabled()) {
this.annotator.emit(ANNOTATOR_EVENT.setVisibility, false);
this.disableAnnotationControls();
this.processAnnotationModeChange(this.annotationControlsFSM.transition(AnnotationInput.RESET));
}
}

Expand Down Expand Up @@ -919,8 +918,8 @@ class BaseViewer extends EventEmitter {
disableAnnotationControls() {
if (this.annotator && this.annotationControls && this.areNewAnnotationsEnabled()) {
this.annotator.toggleAnnotationMode(AnnotationMode.NONE);
this.annotationControls.resetControls();
this.annotationControls.toggle(false);
this.processAnnotationModeChange(this.annotationControlsFSM.transition(AnnotationInput.RESET));
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,20 +1045,22 @@ describe('lib/viewers/BaseViewer', () => {
describe('disableAnnotationControls()', () => {
test('should hide annotations and toggle annotations mode', () => {
jest.spyOn(base, 'areNewAnnotationsEnabled').mockReturnValue(true);
jest.spyOn(base, 'processAnnotationModeChange');

base.annotator = {
toggleAnnotationMode: jest.fn(),
};
base.annotationControls = {
destroy: jest.fn(),
resetControls: jest.fn(),
setMode: jest.fn(),
toggle: jest.fn(),
};

base.disableAnnotationControls();

expect(base.annotationControls.resetControls).toBeCalled();
expect(base.annotationControls.toggle).toBeCalledWith(false);
expect(base.processAnnotationModeChange).toBeCalledWith(AnnotationMode.NONE);
});
});

Expand Down

0 comments on commit b6371a0

Please sign in to comment.