2017-04-21 13:19:08 +00:00
|
|
|
/* global Shortcuts */
|
|
|
|
describe('Shortcuts', () => {
|
2017-08-10 15:48:22 +00:00
|
|
|
const fixtureName = 'merge_requests/diff_comment.html.raw';
|
2017-04-21 15:32:10 +00:00
|
|
|
const createEvent = (type, target) => $.Event(type, {
|
|
|
|
target,
|
|
|
|
});
|
2017-04-21 13:19:08 +00:00
|
|
|
|
|
|
|
preloadFixtures(fixtureName);
|
|
|
|
|
|
|
|
describe('toggleMarkdownPreview', () => {
|
|
|
|
let sc;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
loadFixtures(fixtureName);
|
|
|
|
|
2017-04-21 15:32:10 +00:00
|
|
|
spyOnEvent('.js-new-note-form .js-md-preview-button', 'focus');
|
|
|
|
spyOnEvent('.edit-note .js-md-preview-button', 'focus');
|
2017-04-21 13:19:08 +00:00
|
|
|
|
|
|
|
sc = new Shortcuts();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('focuses preview button in form', () => {
|
2017-04-21 15:32:10 +00:00
|
|
|
sc.toggleMarkdownPreview(
|
|
|
|
createEvent('KeyboardEvent', document.querySelector('.js-new-note-form .js-note-text'),
|
|
|
|
));
|
|
|
|
|
|
|
|
expect('focus').toHaveBeenTriggeredOn('.js-new-note-form .js-md-preview-button');
|
|
|
|
});
|
2017-04-21 13:19:08 +00:00
|
|
|
|
2017-04-21 15:32:10 +00:00
|
|
|
it('focues preview button inside edit comment form', (done) => {
|
|
|
|
document.querySelector('.js-note-edit').click();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
sc.toggleMarkdownPreview(
|
|
|
|
createEvent('KeyboardEvent', document.querySelector('.edit-note .js-note-text'),
|
|
|
|
));
|
|
|
|
|
|
|
|
expect('focus').not.toHaveBeenTriggeredOn('.js-new-note-form .js-md-preview-button');
|
|
|
|
expect('focus').toHaveBeenTriggeredOn('.edit-note .js-md-preview-button');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-04-21 13:19:08 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|