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/frontend/droplab/plugins/ajax_spec.js')
-rw-r--r--spec/frontend/droplab/plugins/ajax_spec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/frontend/droplab/plugins/ajax_spec.js b/spec/frontend/droplab/plugins/ajax_spec.js
new file mode 100644
index 00000000000..1d7576ce420
--- /dev/null
+++ b/spec/frontend/droplab/plugins/ajax_spec.js
@@ -0,0 +1,41 @@
+import AjaxCache from '~/lib/utils/ajax_cache';
+import Ajax from '~/droplab/plugins/ajax';
+
+describe('Ajax', () => {
+ describe('preprocessing', () => {
+ const config = {};
+
+ describe('is not configured', () => {
+ it('passes the data through', () => {
+ const data = ['data'];
+
+ expect(Ajax.preprocessing(config, data)).toEqual(data);
+ });
+ });
+
+ describe('is configured', () => {
+ const processedArray = ['processed'];
+
+ beforeEach(() => {
+ config.preprocessing = () => processedArray;
+ jest.spyOn(config, 'preprocessing').mockImplementation(() => processedArray);
+ });
+
+ it('calls preprocessing', () => {
+ Ajax.preprocessing(config, []);
+
+ expect(config.preprocessing.mock.calls.length).toBe(1);
+ });
+
+ it('overrides AjaxCache', () => {
+ jest.spyOn(AjaxCache, 'override').mockImplementation((endpoint, results) => {
+ expect(results).toEqual(processedArray);
+ });
+
+ Ajax.preprocessing(config, []);
+
+ expect(AjaxCache.override.mock.calls.length).toBe(1);
+ });
+ });
+ });
+});