summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2019-08-15 10:11:36 -0500
committerPaul Slaughter <pslaughter@gitlab.com>2019-08-15 10:11:36 -0500
commite55c7a9a3572ad37a8b69cd2d3db9ab24b5ba5ab (patch)
tree28e81b60678f7ed0b4290c479e8e7bc504313b0b /spec
parent0495615502198e208fb9cb50d29adf26525b9b17 (diff)
downloadgitlab-ce-e55c7a9a3572ad37a8b69cd2d3db9ab24b5ba5ab.tar.gz
Add key unbinds to DiscussionKeyboardNavigatorfe-add-unbinds-to-discussion-keyboard-navigator
Also adds comment to explain why this works on the diff-tab when it's only used in `notes-app`. https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30144#note_204066538
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/notes/components/discussion_keyboard_navigator_spec.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/frontend/notes/components/discussion_keyboard_navigator_spec.js b/spec/frontend/notes/components/discussion_keyboard_navigator_spec.js
index 6d50713999d..8881bedf3cc 100644
--- a/spec/frontend/notes/components/discussion_keyboard_navigator_spec.js
+++ b/spec/frontend/notes/components/discussion_keyboard_navigator_spec.js
@@ -74,4 +74,31 @@ describe('notes/components/discussion_keyboard_navigator', () => {
expect(wrapper.vm.currentDiscussionId).toEqual(expectedPrevId);
});
});
+
+ describe('on destroy', () => {
+ beforeEach(() => {
+ jest.spyOn(Mousetrap, 'unbind');
+
+ createComponent();
+
+ wrapper.destroy();
+ });
+
+ it('unbinds keys', () => {
+ expect(Mousetrap.unbind).toHaveBeenCalledWith('n');
+ expect(Mousetrap.unbind).toHaveBeenCalledWith('p');
+ });
+
+ it('does not call jumpToNextDiscussion when pressing `n`', () => {
+ Mousetrap.trigger('n');
+
+ expect(wrapper.vm.jumpToDiscussion).not.toHaveBeenCalled();
+ });
+
+ it('does not call jumpToNextDiscussion when pressing `p`', () => {
+ Mousetrap.trigger('p');
+
+ expect(wrapper.vm.jumpToDiscussion).not.toHaveBeenCalled();
+ });
+ });
});