Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2019-08-15 18:11:36 +0300
committerPaul Slaughter <pslaughter@gitlab.com>2019-08-15 18:11:36 +0300
commite55c7a9a3572ad37a8b69cd2d3db9ab24b5ba5ab (patch)
tree28e81b60678f7ed0b4290c479e8e7bc504313b0b /spec/frontend/notes
parent0495615502198e208fb9cb50d29adf26525b9b17 (diff)
Add key unbinds to DiscussionKeyboardNavigator
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/frontend/notes')
-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();
+ });
+ });
});