diff options
author | André Luís <aluis@gitlab.com> | 2018-05-22 20:18:58 +0300 |
---|---|---|
committer | André Luís <aluis@gitlab.com> | 2018-05-24 19:39:14 +0300 |
commit | 1bc72f668c4979d6f812f8b82b95ae9239c284ab (patch) | |
tree | cf9465c8375c912e882944e78f8e7e640e11f502 | |
parent | 4909f638f35819a0342810e35642b7f941860591 (diff) |
Use axios mock adapter in the pipelinePoll test
-rw-r--r-- | spec/javascripts/ide/stores/actions/project_spec.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/spec/javascripts/ide/stores/actions/project_spec.js b/spec/javascripts/ide/stores/actions/project_spec.js index 66f2ebdffc3..41fa2f01576 100644 --- a/spec/javascripts/ide/stores/actions/project_spec.js +++ b/spec/javascripts/ide/stores/actions/project_spec.js @@ -1,4 +1,5 @@ import Visibility from 'visibilityjs'; +import MockAdapter from 'axios-mock-adapter'; import { refreshLastCommitData, pollSuccessCallBack } from '~/ide/stores/actions'; import store from '~/ide/stores'; import service from '~/ide/services'; @@ -102,24 +103,22 @@ describe('IDE store project actions', () => { }); describe('pipelinePoll', () => { + let mock; + beforeEach(() => { setProjectState(); jasmine.clock().install(); - spyOn(axios, 'get').and.returnValue( - Promise.resolve({ - status: 200, - headers: { - 'poll-interval': '10000', - }, - data: { - foo: 'bar', - }, - }), - ); + mock = new MockAdapter(axios); + mock + .onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines') + .reply(200, { data: { foo: 'bar' } }, { 'poll-interval': '10000' }); + + spyOn(axios, 'get').and.callThrough(); }); afterEach(() => { jasmine.clock().uninstall(); + mock.restore(); }); it('calls service with last fetched state', done => { |