summaryrefslogtreecommitdiff
path: root/spec/javascripts/shortcuts_dashboard_navigation_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/shortcuts_dashboard_navigation_spec.js')
-rw-r--r--spec/javascripts/shortcuts_dashboard_navigation_spec.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/javascripts/shortcuts_dashboard_navigation_spec.js b/spec/javascripts/shortcuts_dashboard_navigation_spec.js
new file mode 100644
index 00000000000..7cb201e01d8
--- /dev/null
+++ b/spec/javascripts/shortcuts_dashboard_navigation_spec.js
@@ -0,0 +1,23 @@
+import findAndFollowLink from '~/shortcuts_dashboard_navigation';
+
+describe('findAndFollowLink', () => {
+ it('visits a link when the selector exists', () => {
+ const href = '/some/path';
+ const visitUrl = spyOnDependency(findAndFollowLink, 'visitUrl');
+
+ 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', () => {
+ const visitUrl = spyOnDependency(findAndFollowLink, 'visitUrl');
+
+ // this should not throw an exception
+ findAndFollowLink('.this-selector-does-not-exist');
+
+ expect(visitUrl).not.toHaveBeenCalled();
+ });
+});