shortcuts_dashboard_navigation_spec.js 726 Bytes
Newer Older
1 2 3 4 5
import findAndFollowLink from '~/shortcuts_dashboard_navigation';

describe('findAndFollowLink', () => {
  it('visits a link when the selector exists', () => {
    const href = '/some/path';
6
    const visitUrl = spyOnDependency(findAndFollowLink, 'visitUrl');
7 8 9 10 11

    setFixtures(`<a class="my-shortcut" href="${href}">link</a>`);

    findAndFollowLink('.my-shortcut');

12
    expect(visitUrl).toHaveBeenCalledWith(href);
13 14 15
  });

  it('does not throw an exception when the selector does not exist', () => {
16
    const visitUrl = spyOnDependency(findAndFollowLink, 'visitUrl');
17 18 19 20

    // this should not throw an exception
    findAndFollowLink('.this-selector-does-not-exist');

21
    expect(visitUrl).not.toHaveBeenCalled();
22 23
  });
});