summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-08-11 00:13:12 +0100
committerFilipa Lacerda <filipa@gitlab.com>2017-08-11 00:13:12 +0100
commit106f0df394c375673ab963c953c8263d254855a3 (patch)
tree43d23b98b73c688cc3490b437a5d4d4a9085a261 /spec
parente7d8744641f228306bf6c1c992212c877d1ab536 (diff)
downloadgitlab-ce-106f0df394c375673ab963c953c8263d254855a3.tar.gz
Fix broken spec for issuable shortcuts and notes
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/notes/components/issue_note_app_spec.js4
-rw-r--r--spec/javascripts/notes_spec.js9
-rw-r--r--spec/javascripts/shortcuts_issuable_spec.js18
3 files changed, 18 insertions, 13 deletions
diff --git a/spec/javascripts/notes/components/issue_note_app_spec.js b/spec/javascripts/notes/components/issue_note_app_spec.js
index 084dde29ca8..bff0ae96ceb 100644
--- a/spec/javascripts/notes/components/issue_note_app_spec.js
+++ b/spec/javascripts/notes/components/issue_note_app_spec.js
@@ -261,4 +261,8 @@ describe('issue_note_app', () => {
it('should show flash error message when new comment failed to be posted', () => {});
it('should show flash error message when comment failed to be updated', () => {});
});
+
+ describe('shortcuts issuable spec', () => {
+
+ });
});
diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js
index 2b9baa84c0a..d9748369d1d 100644
--- a/spec/javascripts/notes_spec.js
+++ b/spec/javascripts/notes_spec.js
@@ -53,17 +53,18 @@ import '~/notes';
it('modifies the Markdown field', function() {
const changeEvent = document.createEvent('HTMLEvents');
changeEvent.initEvent('change', true, true);
- $('input[type=checkbox]').attr('checked', true)[0].dispatchEvent(changeEvent);
- expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
+ $('input[type=checkbox]').attr('checked', true)[1].dispatchEvent(changeEvent);
+
+ expect($('.js-task-list-field.original-task-list').val()).toBe('- [x] Task List Item');
});
it('submits an ajax request on tasklist:changed', function() {
spyOn(jQuery, 'ajax').and.callFake(function(req) {
expect(req.type).toBe('PATCH');
- expect(req.url).toBe('http://test.host/frontend-fixtures/merge-requests-project/notes/3');
+ expect(req.url).toBe('http://test.host/frontend-fixtures/merge-requests-project/merge_requests/1.json');
return expect(req.data.note).not.toBe(null);
});
- $('.js-task-list-field').trigger('tasklist:changed');
+ $('.js-task-list-field.original-task-list').trigger('tasklist:changed');
});
});
diff --git a/spec/javascripts/shortcuts_issuable_spec.js b/spec/javascripts/shortcuts_issuable_spec.js
index 65da2e8b406..a912e150e9b 100644
--- a/spec/javascripts/shortcuts_issuable_spec.js
+++ b/spec/javascripts/shortcuts_issuable_spec.js
@@ -9,7 +9,7 @@ describe('ShortcutsIssuable', () => {
beforeEach(() => {
loadFixtures(fixtureName);
document.querySelector('.js-new-note-form').classList.add('js-main-target-form');
- this.shortcut = new ShortcutsIssuable();
+ this.shortcut = new ShortcutsIssuable(true);
});
describe('replyWithSelectedText', () => {
// Stub window.gl.utils.getSelectedFragment to return a node with the provided HTML.
@@ -21,15 +21,15 @@ describe('ShortcutsIssuable', () => {
};
};
beforeEach(() => {
- this.selector = 'form.js-main-target-form textarea#note-body';
+ this.selector = '.js-main-target-form #note_note';
});
describe('with empty selection', () => {
it('does not return an error', () => {
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect($(this.selector).val()).toBe('');
});
it('triggers `focus`', () => {
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect(document.activeElement).toBe(document.querySelector(this.selector));
});
});
@@ -40,7 +40,7 @@ describe('ShortcutsIssuable', () => {
it('leaves existing input intact', () => {
$(this.selector).val('This text was already here.');
expect($(this.selector).val()).toBe('This text was already here.');
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect($(this.selector).val()).toBe('This text was already here.\n\n> Selected text.\n\n');
});
it('triggers `input`', () => {
@@ -48,25 +48,25 @@ describe('ShortcutsIssuable', () => {
$(this.selector).on('input', () => {
triggered = true;
});
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect(triggered).toBe(true);
});
it('triggers `focus`', () => {
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect(document.activeElement).toBe(document.querySelector(this.selector));
});
});
describe('with a one-line selection', () => {
it('quotes the selection', () => {
stubSelection('<p>This text has been selected.</p>');
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect($(this.selector).val()).toBe('> This text has been selected.\n\n');
});
});
describe('with a multi-line selection', () => {
it('quotes the selected lines as a group', () => {
stubSelection('<p>Selected line one.</p>\n\n<p>Selected line two.</p>\n\n<p>Selected line three.</p>');
- this.shortcut.replyWithSelectedText();
+ this.shortcut.replyWithSelectedText(true);
expect($(this.selector).val()).toBe('> Selected line one.\n>\n> Selected line two.\n>\n> Selected line three.\n\n');
});
});