diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-19 09:08:12 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-19 09:08:12 +0000 |
commit | 57d1bb82549c6713f87f87d5f35eec3d867c83db (patch) | |
tree | 22f708344121786e286fd318fbfbfda632200909 /spec/frontend/lib/utils/navigation_utility_spec.js | |
parent | 4e81d9c050bfea4c866329155c17b929d7381340 (diff) | |
download | gitlab-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.js | 23 |
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(); + }); +}); |