summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2018-02-07 14:56:14 -0600
committerClement Ho <ClemMakesApps@gmail.com>2018-02-07 14:56:14 -0600
commit943516829cba1ccb843d66756dd230f73cc26583 (patch)
tree71e9917bf09759a0205dde26bb442da215ee08e2
parent710794e1e9cbb2de6a31bf4b41588c827d3b383c (diff)
downloadgitlab-ce-mr-show-dispatcher-refactor.tar.gz
Remove spec that spies on Autosize()mr-show-dispatcher-refactor
-rw-r--r--app/assets/javascripts/gl_form.js10
-rw-r--r--spec/javascripts/gl_form_spec.js22
2 files changed, 8 insertions, 24 deletions
diff --git a/app/assets/javascripts/gl_form.js b/app/assets/javascripts/gl_form.js
index 8475ffb93f0..d200044b79f 100644
--- a/app/assets/javascripts/gl_form.js
+++ b/app/assets/javascripts/gl_form.js
@@ -1,12 +1,10 @@
-import Autosize from 'autosize';
+import autosize from 'autosize';
import GfmAutoComplete from './gfm_auto_complete';
import dropzoneInput from './dropzone_input';
import textUtils from './lib/utils/text_markdown';
-let autosize = Autosize; // So we can stub in tests
-
export default class GLForm {
- constructor(form, enableGFM = false, autoSize) {
+ constructor(form, enableGFM = false) {
this.form = form;
this.textarea = this.form.find('textarea.js-gfm-input');
this.enableGFM = enableGFM;
@@ -15,10 +13,6 @@ export default class GLForm {
// Setup the form
this.setupForm();
this.form.data('gl-form', this);
-
- if (autoSize) {
- autosize = autoSize;
- }
}
destroy() {
diff --git a/spec/javascripts/gl_form_spec.js b/spec/javascripts/gl_form_spec.js
index 3c42e027552..9c1fc0fda9e 100644
--- a/spec/javascripts/gl_form_spec.js
+++ b/spec/javascripts/gl_form_spec.js
@@ -1,12 +1,8 @@
-import Autosize from 'autosize';
+import autosize from 'autosize';
import GLForm from '~/gl_form';
import '~/lib/utils/text_utility';
import '~/lib/utils/common_utils';
-const autosizeWrapper = {
- autosize: Autosize,
-};
-
describe('GLForm', () => {
describe('when instantiated', function () {
beforeEach((done) => {
@@ -15,14 +11,12 @@ describe('GLForm', () => {
spyOn($.prototype, 'off').and.returnValue(this.textarea);
spyOn($.prototype, 'on').and.returnValue(this.textarea);
spyOn($.prototype, 'css');
- spyOn(autosizeWrapper, 'autosize');
- this.glForm = new GLForm(this.form, false, autosizeWrapper.autosize);
+ this.glForm = new GLForm(this.form, false);
setTimeout(() => {
$.prototype.off.calls.reset();
$.prototype.on.calls.reset();
$.prototype.css.calls.reset();
- autosizeWrapper.autosize.calls.reset();
done();
});
});
@@ -45,10 +39,6 @@ describe('GLForm', () => {
expect($.prototype.on).toHaveBeenCalledWith('mouseup.autosize', jasmine.any(Function));
});
- it('should autosize the textarea', () => {
- expect(autosizeWrapper.autosize).toHaveBeenCalledWith(jasmine.any(Object));
- });
-
it('should set the resize css property to vertical', () => {
expect($.prototype.css).toHaveBeenCalledWith('resize', 'vertical');
});
@@ -76,7 +66,7 @@ describe('GLForm', () => {
spyOn($.prototype, 'data');
spyOn($.prototype, 'outerHeight').and.returnValue(200);
spyOn(window, 'outerHeight').and.returnValue(400);
- spyOn(autosizeWrapper.autosize, 'destroy');
+ spyOn(autosize, 'destroy');
this.glForm.destroyAutosize();
});
@@ -90,7 +80,7 @@ describe('GLForm', () => {
});
it('should call autosize destroy', () => {
- expect(autosizeWrapper.autosize.destroy).toHaveBeenCalledWith(this.textarea);
+ expect(autosize.destroy).toHaveBeenCalledWith(this.textarea);
});
it('should set the data-height attribute', () => {
@@ -109,9 +99,9 @@ describe('GLForm', () => {
it('should return undefined if the data-height equals the outerHeight', () => {
spyOn($.prototype, 'outerHeight').and.returnValue(200);
spyOn($.prototype, 'data').and.returnValue(200);
- spyOn(autosizeWrapper.autosize, 'destroy');
+ spyOn(autosize, 'destroy');
expect(this.glForm.destroyAutosize()).toBeUndefined();
- expect(autosizeWrapper.autosize.destroy).not.toHaveBeenCalled();
+ expect(autosize.destroy).not.toHaveBeenCalled();
});
});
});