diff options
| author | Mike Greiling <mike@pixelcog.com> | 2018-09-18 14:43:46 -0500 |
|---|---|---|
| committer | Mike Greiling <mike@pixelcog.com> | 2018-09-18 14:43:46 -0500 |
| commit | 08c3920ce14628e90244fba5f580ca4d7bdabdbd (patch) | |
| tree | 144f3b3fea8c7fd52d234e784b4d0314fec0561b /spec/javascripts/lib/utils | |
| parent | df1eb4fa6cff17e228c3f45d60ab3037d2956914 (diff) | |
| download | gitlab-ce-08c3920ce14628e90244fba5f580ca4d7bdabdbd.tar.gz | |
Move findAndFollowLink to lib/utils
Diffstat (limited to 'spec/javascripts/lib/utils')
| -rw-r--r-- | spec/javascripts/lib/utils/navigation_utility_spec.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/navigation_utility_spec.js b/spec/javascripts/lib/utils/navigation_utility_spec.js new file mode 100644 index 00000000000..be620e4a27c --- /dev/null +++ b/spec/javascripts/lib/utils/navigation_utility_spec.js @@ -0,0 +1,23 @@ +import findAndFollowLink from '~/lib/utils/navigation_utility'; + +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(); + }); +}); |
