diff options
Diffstat (limited to 'spec/javascripts/lib/utils/ajax_cache_spec.js')
-rw-r--r-- | spec/javascripts/lib/utils/ajax_cache_spec.js | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/spec/javascripts/lib/utils/ajax_cache_spec.js b/spec/javascripts/lib/utils/ajax_cache_spec.js index 7603400b55e..dc0b04173bf 100644 --- a/spec/javascripts/lib/utils/ajax_cache_spec.js +++ b/spec/javascripts/lib/utils/ajax_cache_spec.js @@ -9,8 +9,8 @@ describe('AjaxCache', () => { }; beforeEach(() => { - AjaxCache.internalStorage = { }; - AjaxCache.pendingRequests = { }; + AjaxCache.internalStorage = {}; + AjaxCache.pendingRequests = {}; }); describe('get', () => { @@ -59,7 +59,7 @@ describe('AjaxCache', () => { it('does nothing if cache is empty', () => { AjaxCache.remove(dummyEndpoint); - expect(AjaxCache.internalStorage).toEqual({ }); + expect(AjaxCache.internalStorage).toEqual({}); }); it('does nothing if cache contains no matching data', () => { @@ -75,7 +75,7 @@ describe('AjaxCache', () => { AjaxCache.remove(dummyEndpoint); - expect(AjaxCache.internalStorage).toEqual({ }); + expect(AjaxCache.internalStorage).toEqual({}); }); }); @@ -101,61 +101,61 @@ describe('AjaxCache', () => { mock.restore(); }); - it('stores and returns data from Ajax call if cache is empty', (done) => { + it('stores and returns data from Ajax call if cache is empty', done => { mock.onGet(dummyEndpoint).reply(200, dummyResponse); AjaxCache.retrieve(dummyEndpoint) - .then((data) => { - expect(data).toEqual(dummyResponse); - expect(AjaxCache.internalStorage[dummyEndpoint]).toEqual(dummyResponse); - }) - .then(done) - .catch(fail); + .then(data => { + expect(data).toEqual(dummyResponse); + expect(AjaxCache.internalStorage[dummyEndpoint]).toEqual(dummyResponse); + }) + .then(done) + .catch(fail); }); - it('makes no Ajax call if request is pending', (done) => { + it('makes no Ajax call if request is pending', done => { mock.onGet(dummyEndpoint).reply(200, dummyResponse); AjaxCache.retrieve(dummyEndpoint) - .then(done) - .catch(fail); + .then(done) + .catch(fail); AjaxCache.retrieve(dummyEndpoint) - .then(done) - .catch(fail); + .then(done) + .catch(fail); expect(axios.get.calls.count()).toBe(1); }); - it('returns undefined if Ajax call fails and cache is empty', (done) => { + it('returns undefined if Ajax call fails and cache is empty', done => { const errorMessage = 'Network Error'; mock.onGet(dummyEndpoint).networkError(); AjaxCache.retrieve(dummyEndpoint) - .then(data => fail(`Received unexpected data: ${JSON.stringify(data)}`)) - .catch((error) => { - expect(error.message).toBe(`${dummyEndpoint}: ${errorMessage}`); - expect(error.textStatus).toBe(errorMessage); - done(); - }) - .catch(fail); + .then(data => fail(`Received unexpected data: ${JSON.stringify(data)}`)) + .catch(error => { + expect(error.message).toBe(`${dummyEndpoint}: ${errorMessage}`); + expect(error.textStatus).toBe(errorMessage); + done(); + }) + .catch(fail); }); - it('makes no Ajax call if matching data exists', (done) => { + it('makes no Ajax call if matching data exists', done => { AjaxCache.internalStorage[dummyEndpoint] = dummyResponse; mock.onGet(dummyEndpoint).reply(() => { fail(new Error('expected no Ajax call!')); }); AjaxCache.retrieve(dummyEndpoint) - .then((data) => { - expect(data).toBe(dummyResponse); - }) - .then(done) - .catch(fail); + .then(data => { + expect(data).toBe(dummyResponse); + }) + .then(done) + .catch(fail); }); - it('makes Ajax call even if matching data exists when forceRequest parameter is provided', (done) => { + it('makes Ajax call even if matching data exists when forceRequest parameter is provided', done => { const oldDummyResponse = { important: 'old dummy data', }; @@ -166,7 +166,7 @@ describe('AjaxCache', () => { // Call without forceRetrieve param AjaxCache.retrieve(dummyEndpoint) - .then((data) => { + .then(data => { expect(data).toBe(oldDummyResponse); }) .then(done) @@ -174,7 +174,7 @@ describe('AjaxCache', () => { // Call with forceRetrieve param AjaxCache.retrieve(dummyEndpoint, true) - .then((data) => { + .then(data => { expect(data).toEqual(dummyResponse); }) .then(done) |