summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils/navigation_utility_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-19 09:08:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-19 09:08:12 +0000
commit57d1bb82549c6713f87f87d5f35eec3d867c83db (patch)
tree22f708344121786e286fd318fbfbfda632200909 /spec/frontend/lib/utils/navigation_utility_spec.js
parent4e81d9c050bfea4c866329155c17b929d7381340 (diff)
downloadgitlab-ce-57d1bb82549c6713f87f87d5f35eec3d867c83db.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils/navigation_utility_spec.js')
-rw-r--r--spec/frontend/lib/utils/navigation_utility_spec.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/navigation_utility_spec.js b/spec/frontend/lib/utils/navigation_utility_spec.js
new file mode 100644
index 00000000000..88172f38894
--- /dev/null
+++ b/spec/frontend/lib/utils/navigation_utility_spec.js
@@ -0,0 +1,23 @@
+import findAndFollowLink from '~/lib/utils/navigation_utility';
+import { visitUrl } from '~/lib/utils/url_utility';
+
+jest.mock('~/lib/utils/url_utility');
+
+describe('findAndFollowLink', () => {
+ it('visits a link when the selector exists', () => {
+ const href = '/some/path';
+
+ setFixtures(`<a class="my-shortcut" href="${href}">link</a>`);
+
+ findAndFollowLink('.my-shortcut');
+
+ expect(visitUrl).toHaveBeenCalledWith(href);
+ });
+
+ it('does not throw an exception when the selector does not exist', () => {
+ // this should not throw an exception
+ findAndFollowLink('.this-selector-does-not-exist');
+
+ expect(visitUrl).not.toHaveBeenCalled();
+ });
+});