Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/droplab/plugins')
-rw-r--r--spec/javascripts/droplab/plugins/ajax_filter_spec.js10
-rw-r--r--spec/javascripts/droplab/plugins/ajax_spec.js2
-rw-r--r--spec/javascripts/droplab/plugins/input_setter_spec.js98
3 files changed, 57 insertions, 53 deletions
diff --git a/spec/javascripts/droplab/plugins/ajax_filter_spec.js b/spec/javascripts/droplab/plugins/ajax_filter_spec.js
index 8155d98b543..5dbe50af07f 100644
--- a/spec/javascripts/droplab/plugins/ajax_filter_spec.js
+++ b/spec/javascripts/droplab/plugins/ajax_filter_spec.js
@@ -38,8 +38,8 @@ describe('AjaxFilter', () => {
dummyList.list.appendChild(dynamicList);
});
- it('calls onLoadingFinished after loading data', (done) => {
- ajaxSpy = (url) => {
+ it('calls onLoadingFinished after loading data', done => {
+ ajaxSpy = url => {
expect(url).toBe('dummy endpoint?dummy search key=');
return Promise.resolve(dummyData);
};
@@ -52,16 +52,16 @@ describe('AjaxFilter', () => {
.catch(done.fail);
});
- it('does not call onLoadingFinished if Ajax call fails', (done) => {
+ it('does not call onLoadingFinished if Ajax call fails', done => {
const dummyError = new Error('My dummy is sick! :-(');
- ajaxSpy = (url) => {
+ ajaxSpy = url => {
expect(url).toBe('dummy endpoint?dummy search key=');
return Promise.reject(dummyError);
};
AjaxFilter.trigger()
.then(done.fail)
- .catch((error) => {
+ .catch(error => {
expect(error).toBe(dummyError);
expect(dummyConfig.onLoadingFinished.calls.count()).toBe(0);
})
diff --git a/spec/javascripts/droplab/plugins/ajax_spec.js b/spec/javascripts/droplab/plugins/ajax_spec.js
index 69fe431e1b9..2f492d00c0a 100644
--- a/spec/javascripts/droplab/plugins/ajax_spec.js
+++ b/spec/javascripts/droplab/plugins/ajax_spec.js
@@ -29,7 +29,7 @@ describe('Ajax', () => {
it('overrides AjaxCache', () => {
spyOn(AjaxCache, 'override').and.callFake((endpoint, results) => {
- expect(results).toEqual(processedArray);
+ expect(results).toEqual(processedArray);
});
Ajax.preprocessing(config, []);
diff --git a/spec/javascripts/droplab/plugins/input_setter_spec.js b/spec/javascripts/droplab/plugins/input_setter_spec.js
index 1988811a305..711e0486bff 100644
--- a/spec/javascripts/droplab/plugins/input_setter_spec.js
+++ b/spec/javascripts/droplab/plugins/input_setter_spec.js
@@ -1,8 +1,8 @@
import InputSetter from '~/droplab/plugins/input_setter';
-describe('InputSetter', function () {
- describe('init', function () {
- beforeEach(function () {
+describe('InputSetter', function() {
+ describe('init', function() {
+ beforeEach(function() {
this.config = { InputSetter: {} };
this.hook = { config: this.config };
this.inputSetter = jasmine.createSpyObj('inputSetter', ['addEvents']);
@@ -10,60 +10,62 @@ describe('InputSetter', function () {
InputSetter.init.call(this.inputSetter, this.hook);
});
- it('should set .hook', function () {
+ it('should set .hook', function() {
expect(this.inputSetter.hook).toBe(this.hook);
});
- it('should set .config', function () {
+ it('should set .config', function() {
expect(this.inputSetter.config).toBe(this.config.InputSetter);
});
- it('should set .eventWrapper', function () {
+ it('should set .eventWrapper', function() {
expect(this.inputSetter.eventWrapper).toEqual({});
});
- it('should call .addEvents', function () {
+ it('should call .addEvents', function() {
expect(this.inputSetter.addEvents).toHaveBeenCalled();
});
- describe('if config.InputSetter is not set', function () {
- beforeEach(function () {
+ describe('if config.InputSetter is not set', function() {
+ beforeEach(function() {
this.config = { InputSetter: undefined };
this.hook = { config: this.config };
InputSetter.init.call(this.inputSetter, this.hook);
});
- it('should set .config to an empty object', function () {
+ it('should set .config to an empty object', function() {
expect(this.inputSetter.config).toEqual({});
});
- it('should set hook.config to an empty object', function () {
+ it('should set hook.config to an empty object', function() {
expect(this.hook.config.InputSetter).toEqual({});
});
- })
+ });
});
- describe('addEvents', function () {
- beforeEach(function () {
+ describe('addEvents', function() {
+ beforeEach(function() {
this.hook = { list: { list: jasmine.createSpyObj('list', ['addEventListener']) } };
this.inputSetter = { eventWrapper: {}, hook: this.hook, setInputs: () => {} };
InputSetter.addEvents.call(this.inputSetter);
});
- it('should set .eventWrapper.setInputs', function () {
+ it('should set .eventWrapper.setInputs', function() {
expect(this.inputSetter.eventWrapper.setInputs).toEqual(jasmine.any(Function));
});
- it('should call .addEventListener', function () {
- expect(this.hook.list.list.addEventListener)
- .toHaveBeenCalledWith('click.dl', this.inputSetter.eventWrapper.setInputs);
+ it('should call .addEventListener', function() {
+ expect(this.hook.list.list.addEventListener).toHaveBeenCalledWith(
+ 'click.dl',
+ this.inputSetter.eventWrapper.setInputs,
+ );
});
});
- describe('removeEvents', function () {
- beforeEach(function () {
+ describe('removeEvents', function() {
+ beforeEach(function() {
this.hook = { list: { list: jasmine.createSpyObj('list', ['removeEventListener']) } };
this.eventWrapper = jasmine.createSpyObj('eventWrapper', ['setInputs']);
this.inputSetter = { eventWrapper: this.eventWrapper, hook: this.hook };
@@ -71,14 +73,16 @@ describe('InputSetter', function () {
InputSetter.removeEvents.call(this.inputSetter);
});
- it('should call .removeEventListener', function () {
- expect(this.hook.list.list.removeEventListener)
- .toHaveBeenCalledWith('click.dl', this.eventWrapper.setInputs);
+ it('should call .removeEventListener', function() {
+ expect(this.hook.list.list.removeEventListener).toHaveBeenCalledWith(
+ 'click.dl',
+ this.eventWrapper.setInputs,
+ );
});
});
- describe('setInputs', function () {
- beforeEach(function () {
+ describe('setInputs', function() {
+ beforeEach(function() {
this.event = { detail: { selected: {} } };
this.config = [0, 1];
this.inputSetter = { config: this.config, setInput: () => {} };
@@ -88,7 +92,7 @@ describe('InputSetter', function () {
InputSetter.setInputs.call(this.inputSetter, this.event);
});
- it('should call .setInput for each config element', function () {
+ it('should call .setInput for each config element', function() {
const allArgs = this.inputSetter.setInput.calls.allArgs();
expect(allArgs.length).toEqual(2);
@@ -99,21 +103,21 @@ describe('InputSetter', function () {
});
});
- describe('if config isnt an array', function () {
- beforeEach(function () {
+ describe('if config isnt an array', function() {
+ beforeEach(function() {
this.inputSetter = { config: {}, setInput: () => {} };
InputSetter.setInputs.call(this.inputSetter, this.event);
});
- it('should set .config to an array with .config as the first element', function () {
+ it('should set .config to an array with .config as the first element', function() {
expect(this.inputSetter.config).toEqual([{}]);
});
});
});
- describe('setInput', function () {
- beforeEach(function () {
+ describe('setInput', function() {
+ beforeEach(function() {
this.selectedItem = { getAttribute: () => {} };
this.input = { value: 'oldValue', tagName: 'INPUT', hasAttribute: () => {} };
this.config = { valueAttribute: {}, input: this.input };
@@ -126,20 +130,20 @@ describe('InputSetter', function () {
InputSetter.setInput.call(this.inputSetter, this.config, this.selectedItem);
});
- it('should call .getAttribute', function () {
+ it('should call .getAttribute', function() {
expect(this.selectedItem.getAttribute).toHaveBeenCalledWith(this.config.valueAttribute);
});
- it('should call .hasAttribute', function () {
+ it('should call .hasAttribute', function() {
expect(this.input.hasAttribute).toHaveBeenCalledWith(undefined);
});
- it('should set the value of the input', function () {
+ it('should set the value of the input', function() {
expect(this.input.value).toBe(this.newValue);
});
- describe('if no config.input is provided', function () {
- beforeEach(function () {
+ describe('if no config.input is provided', function() {
+ beforeEach(function() {
this.config = { valueAttribute: {} };
this.trigger = { value: 'oldValue', tagName: 'INPUT', hasAttribute: () => {} };
this.inputSetter = { hook: { trigger: this.trigger } };
@@ -147,26 +151,26 @@ describe('InputSetter', function () {
InputSetter.setInput.call(this.inputSetter, this.config, this.selectedItem);
});
- it('should set the value of the hook.trigger', function () {
+ it('should set the value of the hook.trigger', function() {
expect(this.trigger.value).toBe(this.newValue);
});
});
- describe('if the input tag is not INPUT', function () {
- beforeEach(function () {
+ describe('if the input tag is not INPUT', function() {
+ beforeEach(function() {
this.input = { textContent: 'oldValue', tagName: 'SPAN', hasAttribute: () => {} };
this.config = { valueAttribute: {}, input: this.input };
InputSetter.setInput.call(this.inputSetter, this.config, this.selectedItem);
});
- it('should set the textContent of the input', function () {
+ it('should set the textContent of the input', function() {
expect(this.input.textContent).toBe(this.newValue);
});
});
- describe('if there is an inputAttribute', function () {
- beforeEach(function () {
+ describe('if there is an inputAttribute', function() {
+ beforeEach(function() {
this.selectedItem = { getAttribute: () => {} };
this.input = { id: 'oldValue', hasAttribute: () => {}, setAttribute: () => {} };
this.inputSetter = { hook: { trigger: {} } };
@@ -185,25 +189,25 @@ describe('InputSetter', function () {
InputSetter.setInput.call(this.inputSetter, this.config, this.selectedItem);
});
- it('should call setAttribute', function () {
+ it('should call setAttribute', function() {
expect(this.input.setAttribute).toHaveBeenCalledWith(this.inputAttribute, this.newValue);
});
- it('should not set the value or textContent of the input', function () {
+ it('should not set the value or textContent of the input', function() {
expect(this.input.value).not.toBe('newValue');
expect(this.input.textContent).not.toBe('newValue');
});
});
});
- describe('destroy', function () {
- beforeEach(function () {
+ describe('destroy', function() {
+ beforeEach(function() {
this.inputSetter = jasmine.createSpyObj('inputSetter', ['removeEvents']);
InputSetter.destroy.call(this.inputSetter);
});
- it('should call .removeEvents', function () {
+ it('should call .removeEvents', function() {
expect(this.inputSetter.removeEvents).toHaveBeenCalled();
});
});