gitlab-ce/spec/frontend/projects/behaviors_spec.js

24 lines
748 B
JavaScript

import { initFindFileShortcut } from '~/projects/behaviors';
import Shortcuts from '~/behaviors/shortcuts/shortcuts';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
describe('initFindFileShortcut', () => {
const fixture = '<button class="shortcuts-find-file">Find file</button>';
beforeEach(() => setHTMLFixture(fixture));
afterEach(() => resetHTMLFixture());
it('add a `click` eventListener to the find file button', () => {
const findFileButton = document.querySelector('.shortcuts-find-file');
jest.spyOn(findFileButton, 'addEventListener');
initFindFileShortcut();
expect(findFileButton.addEventListener).toHaveBeenCalledWith(
'click',
Shortcuts.focusSearchFile,
);
});
});