summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-04-12 15:12:58 +0000
committerPhil Hughes <me@iamphill.com>2019-04-12 15:12:58 +0000
commit9edb5d47808fe9618aed0f411c6b5aebbaadd42a (patch)
treee0cf01d5c132f7623393075515feaeb45d4aa708 /spec
parent7728212b050d121833b2709e2eac46a766001a9e (diff)
parent2ea409f6e18150615610e09979bda73fc5bff9e8 (diff)
downloadgitlab-ce-9edb5d47808fe9618aed0f411c6b5aebbaadd42a.tar.gz
Merge branch '60241-merge-request-popover-doesn-t-go-away-on-mouse-leave' into 'master'
Resolve "Merge Request popover doesn't go away on mouse leave" Closes #60241 See merge request gitlab-org/gitlab-ce!27143
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/mr_popover/index_spec.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/frontend/mr_popover/index_spec.js b/spec/frontend/mr_popover/index_spec.js
new file mode 100644
index 00000000000..8c33e52a04b
--- /dev/null
+++ b/spec/frontend/mr_popover/index_spec.js
@@ -0,0 +1,30 @@
+import * as createDefaultClient from '~/lib/graphql';
+import { setHTMLFixture } from '../helpers/fixtures';
+import initMRPopovers from '~/mr_popover/index';
+
+createDefaultClient.default = jest.fn();
+
+describe('initMRPopovers', () => {
+ let mr1;
+ let mr2;
+
+ beforeEach(() => {
+ setHTMLFixture(`
+ <div id="one" class="gfm-merge_request">MR1</div>
+ <div id="two" class="gfm-merge_request">MR2</div>
+ `);
+
+ mr1 = document.querySelector('#one');
+ mr2 = document.querySelector('#two');
+
+ mr1.addEventListener = jest.fn();
+ mr2.addEventListener = jest.fn();
+ });
+
+ it('does not add the same event listener twice', () => {
+ initMRPopovers([mr1, mr1, mr2]);
+
+ expect(mr1.addEventListener).toHaveBeenCalledTimes(1);
+ expect(mr2.addEventListener).toHaveBeenCalledTimes(1);
+ });
+});