blob: 88172f38894e0c4663e44b04745f20fe44253a92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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();
});
});
|