summaryrefslogtreecommitdiff
path: root/spec/javascripts/behaviors
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-10-17 02:13:26 -0500
committerMike Greiling <mike@pixelcog.com>2018-10-17 11:18:17 -0500
commitf666026d71ebefd70219d5078b1f0c83fa01f84d (patch)
treece43feb99c12c21dd266d25de24b1768bac1d459 /spec/javascripts/behaviors
parent5a6fffcffca3dc8e4f52c90d3d18eaefd9e48aef (diff)
downloadgitlab-ce-f666026d71ebefd70219d5078b1f0c83fa01f84d.tar.gz
Prettify all spec files
Diffstat (limited to 'spec/javascripts/behaviors')
-rw-r--r--spec/javascripts/behaviors/bind_in_out_spec.js113
-rw-r--r--spec/javascripts/behaviors/copy_as_gfm_spec.js2
-rw-r--r--spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js4
-rw-r--r--spec/javascripts/behaviors/quick_submit_spec.js2
-rw-r--r--spec/javascripts/behaviors/requires_input_spec.js24
-rw-r--r--spec/javascripts/behaviors/secret_values_spec.js31
6 files changed, 94 insertions, 82 deletions
diff --git a/spec/javascripts/behaviors/bind_in_out_spec.js b/spec/javascripts/behaviors/bind_in_out_spec.js
index 5ff66167718..0c214f5886a 100644
--- a/spec/javascripts/behaviors/bind_in_out_spec.js
+++ b/spec/javascripts/behaviors/bind_in_out_spec.js
@@ -1,60 +1,60 @@
import BindInOut from '~/behaviors/bind_in_out';
import ClassSpecHelper from '../helpers/class_spec_helper';
-describe('BindInOut', function () {
- describe('constructor', function () {
- beforeEach(function () {
+describe('BindInOut', function() {
+ describe('constructor', function() {
+ beforeEach(function() {
this.in = {};
this.out = {};
this.bindInOut = new BindInOut(this.in, this.out);
});
- it('should set .in', function () {
+ it('should set .in', function() {
expect(this.bindInOut.in).toBe(this.in);
});
- it('should set .out', function () {
+ it('should set .out', function() {
expect(this.bindInOut.out).toBe(this.out);
});
- it('should set .eventWrapper', function () {
+ it('should set .eventWrapper', function() {
expect(this.bindInOut.eventWrapper).toEqual({});
});
- describe('if .in is an input', function () {
- beforeEach(function () {
+ describe('if .in is an input', function() {
+ beforeEach(function() {
this.bindInOut = new BindInOut({ tagName: 'INPUT' });
});
- it('should set .eventType to keyup ', function () {
+ it('should set .eventType to keyup ', function() {
expect(this.bindInOut.eventType).toEqual('keyup');
});
});
- describe('if .in is a textarea', function () {
- beforeEach(function () {
+ describe('if .in is a textarea', function() {
+ beforeEach(function() {
this.bindInOut = new BindInOut({ tagName: 'TEXTAREA' });
});
- it('should set .eventType to keyup ', function () {
+ it('should set .eventType to keyup ', function() {
expect(this.bindInOut.eventType).toEqual('keyup');
});
});
- describe('if .in is not an input or textarea', function () {
- beforeEach(function () {
+ describe('if .in is not an input or textarea', function() {
+ beforeEach(function() {
this.bindInOut = new BindInOut({ tagName: 'SELECT' });
});
- it('should set .eventType to change ', function () {
+ it('should set .eventType to change ', function() {
expect(this.bindInOut.eventType).toEqual('change');
});
});
});
- describe('addEvents', function () {
- beforeEach(function () {
+ describe('addEvents', function() {
+ beforeEach(function() {
this.in = jasmine.createSpyObj('in', ['addEventListener']);
this.bindInOut = new BindInOut(this.in);
@@ -62,25 +62,24 @@ describe('BindInOut', function () {
this.addEvents = this.bindInOut.addEvents();
});
- it('should set .eventWrapper.updateOut', function () {
+ it('should set .eventWrapper.updateOut', function() {
expect(this.bindInOut.eventWrapper.updateOut).toEqual(jasmine.any(Function));
});
- it('should call .addEventListener', function () {
- expect(this.in.addEventListener)
- .toHaveBeenCalledWith(
- this.bindInOut.eventType,
- this.bindInOut.eventWrapper.updateOut,
- );
+ it('should call .addEventListener', function() {
+ expect(this.in.addEventListener).toHaveBeenCalledWith(
+ this.bindInOut.eventType,
+ this.bindInOut.eventWrapper.updateOut,
+ );
});
- it('should return the instance', function () {
+ it('should return the instance', function() {
expect(this.addEvents).toBe(this.bindInOut);
});
});
- describe('updateOut', function () {
- beforeEach(function () {
+ describe('updateOut', function() {
+ beforeEach(function() {
this.in = { value: 'the-value' };
this.out = { textContent: 'not-the-value' };
@@ -89,17 +88,17 @@ describe('BindInOut', function () {
this.updateOut = this.bindInOut.updateOut();
});
- it('should set .out.textContent to .in.value', function () {
+ it('should set .out.textContent to .in.value', function() {
expect(this.out.textContent).toBe(this.in.value);
});
- it('should return the instance', function () {
+ it('should return the instance', function() {
expect(this.updateOut).toBe(this.bindInOut);
});
});
- describe('removeEvents', function () {
- beforeEach(function () {
+ describe('removeEvents', function() {
+ beforeEach(function() {
this.in = jasmine.createSpyObj('in', ['removeEventListener']);
this.updateOut = () => {};
@@ -109,21 +108,20 @@ describe('BindInOut', function () {
this.removeEvents = this.bindInOut.removeEvents();
});
- it('should call .removeEventListener', function () {
- expect(this.in.removeEventListener)
- .toHaveBeenCalledWith(
- this.bindInOut.eventType,
- this.updateOut,
- );
+ it('should call .removeEventListener', function() {
+ expect(this.in.removeEventListener).toHaveBeenCalledWith(
+ this.bindInOut.eventType,
+ this.updateOut,
+ );
});
- it('should return the instance', function () {
+ it('should return the instance', function() {
expect(this.removeEvents).toBe(this.bindInOut);
});
});
- describe('initAll', function () {
- beforeEach(function () {
+ describe('initAll', function() {
+ beforeEach(function() {
this.ins = [0, 1, 2];
this.instances = [];
@@ -136,43 +134,47 @@ describe('BindInOut', function () {
ClassSpecHelper.itShouldBeAStaticMethod(BindInOut, 'initAll');
- it('should call .querySelectorAll', function () {
+ it('should call .querySelectorAll', function() {
expect(document.querySelectorAll).toHaveBeenCalledWith('*[data-bind-in]');
});
- it('should call .map', function () {
+ it('should call .map', function() {
expect(Array.prototype.map).toHaveBeenCalledWith(jasmine.any(Function));
});
- it('should call .init for each element', function () {
+ it('should call .init for each element', function() {
expect(BindInOut.init.calls.count()).toEqual(3);
});
- it('should return an array of instances', function () {
+ it('should return an array of instances', function() {
expect(this.initAll).toEqual(jasmine.any(Array));
});
});
- describe('init', function () {
- beforeEach(function () {
- spyOn(BindInOut.prototype, 'addEvents').and.callFake(function () { return this; });
- spyOn(BindInOut.prototype, 'updateOut').and.callFake(function () { return this; });
+ describe('init', function() {
+ beforeEach(function() {
+ spyOn(BindInOut.prototype, 'addEvents').and.callFake(function() {
+ return this;
+ });
+ spyOn(BindInOut.prototype, 'updateOut').and.callFake(function() {
+ return this;
+ });
this.init = BindInOut.init({}, {});
});
ClassSpecHelper.itShouldBeAStaticMethod(BindInOut, 'init');
- it('should call .addEvents', function () {
+ it('should call .addEvents', function() {
expect(BindInOut.prototype.addEvents).toHaveBeenCalled();
});
- it('should call .updateOut', function () {
+ it('should call .updateOut', function() {
expect(BindInOut.prototype.updateOut).toHaveBeenCalled();
});
- describe('if no anOut is provided', function () {
- beforeEach(function () {
+ describe('if no anOut is provided', function() {
+ beforeEach(function() {
this.anIn = { dataset: { bindIn: 'the-data-bind-in' } };
spyOn(document, 'querySelector');
@@ -180,9 +182,10 @@ describe('BindInOut', function () {
BindInOut.init(this.anIn);
});
- it('should call .querySelector', function () {
- expect(document.querySelector)
- .toHaveBeenCalledWith(`*[data-bind-out="${this.anIn.dataset.bindIn}"]`);
+ it('should call .querySelector', function() {
+ expect(document.querySelector).toHaveBeenCalledWith(
+ `*[data-bind-out="${this.anIn.dataset.bindIn}"]`,
+ );
});
});
});
diff --git a/spec/javascripts/behaviors/copy_as_gfm_spec.js b/spec/javascripts/behaviors/copy_as_gfm_spec.js
index f0b4fa63f71..cf8c1b77861 100644
--- a/spec/javascripts/behaviors/copy_as_gfm_spec.js
+++ b/spec/javascripts/behaviors/copy_as_gfm_spec.js
@@ -56,7 +56,7 @@ describe('CopyAsGFM', () => {
const fragment = document.createDocumentFragment();
const node = document.createElement('div');
node.innerHTML = html;
- Array.from(node.childNodes).forEach((item) => fragment.appendChild(item));
+ Array.from(node.childNodes).forEach(item => fragment.appendChild(item));
return fragment;
},
}),
diff --git a/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js b/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js
index f96f20ed4a5..f656b97fec2 100644
--- a/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js
+++ b/spec/javascripts/behaviors/gl_emoji/unicode_support_map_spec.js
@@ -13,7 +13,7 @@ describe('Unicode Support Map', () => {
spyOn(JSON, 'stringify').and.returnValue(stringSupportMap);
});
- describe('if isLocalStorageAvailable is `true`', function () {
+ describe('if isLocalStorageAvailable is `true`', function() {
beforeEach(() => {
AccessorUtilities.isLocalStorageAccessSafe.and.returnValue(true);
@@ -36,7 +36,7 @@ describe('Unicode Support Map', () => {
});
});
- describe('if isLocalStorageAvailable is `false`', function () {
+ describe('if isLocalStorageAvailable is `false`', function() {
beforeEach(() => {
AccessorUtilities.isLocalStorageAccessSafe.and.returnValue(false);
diff --git a/spec/javascripts/behaviors/quick_submit_spec.js b/spec/javascripts/behaviors/quick_submit_spec.js
index 1fbc1f7a8e8..681463aab66 100644
--- a/spec/javascripts/behaviors/quick_submit_spec.js
+++ b/spec/javascripts/behaviors/quick_submit_spec.js
@@ -1,7 +1,7 @@
import $ from 'jquery';
import '~/behaviors/quick_submit';
-describe('Quick Submit behavior', function () {
+describe('Quick Submit behavior', function() {
const keydownEvent = (options = { keyCode: 13, metaKey: true }) => $.Event('keydown', options);
preloadFixtures('snippets/show.html.raw');
diff --git a/spec/javascripts/behaviors/requires_input_spec.js b/spec/javascripts/behaviors/requires_input_spec.js
index 5d1cc374573..1bde2bb3024 100644
--- a/spec/javascripts/behaviors/requires_input_spec.js
+++ b/spec/javascripts/behaviors/requires_input_spec.js
@@ -32,18 +32,30 @@ describe('requiresInput', () => {
it('enables submit when all required fields receive input', () => {
$('.js-requires-input').requiresInput();
- $('#required1').val('input1').change();
+ $('#required1')
+ .val('input1')
+ .change();
expect(submitButton).toBeDisabled();
- $('#optional1').val('input1').change();
+ $('#optional1')
+ .val('input1')
+ .change();
expect(submitButton).toBeDisabled();
- $('#required2').val('input2').change();
- $('#required3').val('input3').change();
- $('#required4').val('input4').change();
- $('#required5').val('1').change();
+ $('#required2')
+ .val('input2')
+ .change();
+ $('#required3')
+ .val('input3')
+ .change();
+ $('#required4')
+ .val('input4')
+ .change();
+ $('#required5')
+ .val('1')
+ .change();
expect($('.submit')).not.toBeDisabled();
});
diff --git a/spec/javascripts/behaviors/secret_values_spec.js b/spec/javascripts/behaviors/secret_values_spec.js
index ed42fc099c1..5aaab093c0c 100644
--- a/spec/javascripts/behaviors/secret_values_spec.js
+++ b/spec/javascripts/behaviors/secret_values_spec.js
@@ -36,12 +36,7 @@ function setupSecretFixture(
placeholderClass = 'js-secret-value-placeholder',
) {
const wrapper = document.createElement('div');
- wrapper.innerHTML = generateFixtureMarkup(
- secrets,
- isRevealed,
- valueClass,
- placeholderClass,
- );
+ wrapper.innerHTML = generateFixtureMarkup(secrets, isRevealed, valueClass, placeholderClass);
const secretValues = new SecretValues({
container: wrapper.querySelector('.js-secret-container'),
@@ -127,12 +122,12 @@ describe('setupSecretValues', () => {
const placeholders = wrapper.querySelectorAll('.js-secret-value-placeholder');
expect(values.length).toEqual(3);
- values.forEach((value) => {
+ values.forEach(value => {
expect(value.classList.contains('hide')).toEqual(true);
});
expect(placeholders.length).toEqual(3);
- placeholders.forEach((placeholder) => {
+ placeholders.forEach(placeholder => {
expect(placeholder.classList.contains('hide')).toEqual(false);
});
});
@@ -146,24 +141,24 @@ describe('setupSecretValues', () => {
revealButton.click();
expect(values.length).toEqual(3);
- values.forEach((value) => {
+ values.forEach(value => {
expect(value.classList.contains('hide')).toEqual(false);
});
expect(placeholders.length).toEqual(3);
- placeholders.forEach((placeholder) => {
+ placeholders.forEach(placeholder => {
expect(placeholder.classList.contains('hide')).toEqual(true);
});
revealButton.click();
expect(values.length).toEqual(3);
- values.forEach((value) => {
+ values.forEach(value => {
expect(value.classList.contains('hide')).toEqual(true);
});
expect(placeholders.length).toEqual(3);
- placeholders.forEach((placeholder) => {
+ placeholders.forEach(placeholder => {
expect(placeholder.classList.contains('hide')).toEqual(false);
});
});
@@ -175,7 +170,9 @@ describe('setupSecretValues', () => {
it('should toggle values and placeholders', () => {
const wrapper = setupSecretFixture(secrets, false);
// Insert the new dynamic row
- wrapper.querySelector('.js-secret-container').insertAdjacentHTML('afterbegin', generateValueMarkup('foobarbazdynamic'));
+ wrapper
+ .querySelector('.js-secret-container')
+ .insertAdjacentHTML('afterbegin', generateValueMarkup('foobarbazdynamic'));
const revealButton = wrapper.querySelector('.js-secret-value-reveal-button');
const values = wrapper.querySelectorAll('.js-secret-value');
@@ -184,24 +181,24 @@ describe('setupSecretValues', () => {
revealButton.click();
expect(values.length).toEqual(4);
- values.forEach((value) => {
+ values.forEach(value => {
expect(value.classList.contains('hide')).toEqual(false);
});
expect(placeholders.length).toEqual(4);
- placeholders.forEach((placeholder) => {
+ placeholders.forEach(placeholder => {
expect(placeholder.classList.contains('hide')).toEqual(true);
});
revealButton.click();
expect(values.length).toEqual(4);
- values.forEach((value) => {
+ values.forEach(value => {
expect(value.classList.contains('hide')).toEqual(true);
});
expect(placeholders.length).toEqual(4);
- placeholders.forEach((placeholder) => {
+ placeholders.forEach(placeholder => {
expect(placeholder.classList.contains('hide')).toEqual(false);
});
});