summaryrefslogtreecommitdiff
path: root/spec/javascripts/shortcuts_issuable_spec.js
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-02-02 11:45:58 -0600
committerMike Greiling <mike@pixelcog.com>2017-02-02 11:45:58 -0600
commit7ca57c59c8b29dfbf714b9921583f3544c76bdb3 (patch)
tree52a5cca34c203d5a311e923cc5a474c1a42bf509 /spec/javascripts/shortcuts_issuable_spec.js
parent5a099315eb29c345925141609dc5a3a395312016 (diff)
parent4615d0995117e8369acc7b1f5f2b8497426ba5c7 (diff)
downloadgitlab-ce-7ca57c59c8b29dfbf714b9921583f3544c76bdb3.tar.gz
Merge branch 'master' into webpack
* master: (63 commits) Use `add_$role` helper in snippets specs removes old css class from everywhere Fixes broken build: Use jquery to get the element position in the page Check public snippets for spam Keep snippet visibility on error Update pipeline and commit URL and text on CI status change Support non-ASCII characters in GFM autocomplete Active tense test coverage Fix filtered search manager spec teaspoon error Reduce the number of loops that Cycle Analytics specs use Remove unnecessary returns / unset variables from the CoffeeScript -> JS conversion. update spec Change the reply shortcut to focus the field even without a selection. use destroy_all Remove settings cog from within admin scroll tabs; keep links centered add changelog remove old project members from project add spec replicating validation error Improve styling of the new issue message Don't capitalize environment name in show page ...
Diffstat (limited to 'spec/javascripts/shortcuts_issuable_spec.js')
-rw-r--r--spec/javascripts/shortcuts_issuable_spec.js42
1 files changed, 24 insertions, 18 deletions
diff --git a/spec/javascripts/shortcuts_issuable_spec.js b/spec/javascripts/shortcuts_issuable_spec.js
index 331f36ccc44..602ac01aec3 100644
--- a/spec/javascripts/shortcuts_issuable_spec.js
+++ b/spec/javascripts/shortcuts_issuable_spec.js
@@ -11,9 +11,9 @@ require('~/shortcuts_issuable');
beforeEach(function() {
loadFixtures(fixtureName);
document.querySelector('.js-new-note-form').classList.add('js-main-target-form');
- return this.shortcut = new ShortcutsIssuable();
+ this.shortcut = new ShortcutsIssuable();
});
- return describe('#replyWithSelectedText', function() {
+ describe('#replyWithSelectedText', function() {
var stubSelection;
// Stub window.gl.utils.getSelectedFragment to return a node with the provided HTML.
stubSelection = function(html) {
@@ -24,51 +24,57 @@ require('~/shortcuts_issuable');
};
};
beforeEach(function() {
- return this.selector = 'form.js-main-target-form textarea#note_note';
+ this.selector = 'form.js-main-target-form textarea#note_note';
});
describe('with empty selection', function() {
- return it('does nothing', function() {
- stubSelection('');
+ it('does not return an error', function() {
this.shortcut.replyWithSelectedText();
- return expect($(this.selector).val()).toBe('');
+ expect($(this.selector).val()).toBe('');
+ });
+ it('triggers `input`', function() {
+ var focused = false;
+ $(this.selector).on('focus', function() {
+ focused = true;
+ });
+ this.shortcut.replyWithSelectedText();
+ expect(focused).toBe(true);
});
});
describe('with any selection', function() {
beforeEach(function() {
- return stubSelection('<p>Selected text.</p>');
+ stubSelection('<p>Selected text.</p>');
});
it('leaves existing input intact', function() {
$(this.selector).val('This text was already here.');
expect($(this.selector).val()).toBe('This text was already here.');
this.shortcut.replyWithSelectedText();
- return expect($(this.selector).val()).toBe("This text was already here.\n\n> Selected text.\n\n");
+ expect($(this.selector).val()).toBe("This text was already here.\n\n> Selected text.\n\n");
});
it('triggers `input`', function() {
- var triggered;
- triggered = false;
+ var triggered = false;
$(this.selector).on('input', function() {
- return triggered = true;
+ triggered = true;
});
this.shortcut.replyWithSelectedText();
- return expect(triggered).toBe(true);
+ expect(triggered).toBe(true);
});
- return it('triggers `focus`', function() {
+ it('triggers `focus`', function() {
this.shortcut.replyWithSelectedText();
expect(document.activeElement).toBe(document.querySelector(this.selector));
});
});
describe('with a one-line selection', function() {
- return it('quotes the selection', function() {
+ it('quotes the selection', function() {
stubSelection('<p>This text has been selected.</p>');
this.shortcut.replyWithSelectedText();
- return expect($(this.selector).val()).toBe("> This text has been selected.\n\n");
+ expect($(this.selector).val()).toBe("> This text has been selected.\n\n");
});
});
- return describe('with a multi-line selection', function() {
- return it('quotes the selected lines as a group', function() {
+ describe('with a multi-line selection', function() {
+ it('quotes the selected lines as a group', function() {
stubSelection("<p>Selected line one.</p>\n\n<p>Selected line two.</p>\n\n<p>Selected line three.</p>");
this.shortcut.replyWithSelectedText();
- return expect($(this.selector).val()).toBe("> Selected line one.\n>\n> Selected line two.\n>\n> Selected line three.\n\n");
+ expect($(this.selector).val()).toBe("> Selected line one.\n>\n> Selected line two.\n>\n> Selected line three.\n\n");
});
});
});