Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[courier/request] move source mutation logic out of request
- Loading branch information
Showing
6 changed files
with
110 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/ui/public/courier/fetch/request/__tests__/abstact_request.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ngMock from 'ng_mock'; | ||
import sinon from 'sinon'; | ||
|
||
import { AbstractRequestProvider } from '../request'; | ||
import { requestQueue } from '../../../_request_queue'; | ||
|
||
describe('courier/fetch abstract request', () => { | ||
beforeEach(ngMock.module('kibana')); | ||
|
||
afterEach(() => { | ||
requestQueue.clear(); | ||
}); | ||
|
||
describe('#start()', () => { | ||
it('calls this.source.requestIsStarting(request)', ngMock.inject((Private) => { | ||
const AbstractReq = Private(AbstractRequestProvider); | ||
|
||
const spy = sinon.spy(() => Promise.resolve()); | ||
const source = { requestIsStarting: spy }; | ||
|
||
const req = new AbstractReq(source); | ||
expect(req.start()).to.have.property('then').a('function'); | ||
sinon.assert.calledOnce(spy); | ||
sinon.assert.calledWithExactly(spy, req); | ||
})); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/ui/public/courier/fetch/request/__tests__/search_request.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ngMock from 'ng_mock'; | ||
import sinon from 'sinon'; | ||
|
||
import { SearchRequestProvider } from '../search'; | ||
import { requestQueue } from '../../../_request_queue'; | ||
|
||
describe('ui/courier/fetch search request', () => { | ||
beforeEach(ngMock.module('kibana')); | ||
|
||
afterEach(() => { | ||
requestQueue.clear(); | ||
}); | ||
|
||
describe('#start()', () => { | ||
it('calls this.source.requestIsStarting(request)', ngMock.inject((Private) => { | ||
const SearchReq = Private(SearchRequestProvider); | ||
|
||
const spy = sinon.spy(() => Promise.resolve()); | ||
const source = { requestIsStarting: spy }; | ||
|
||
const req = new SearchReq(source); | ||
expect(req.start()).to.have.property('then').a('function'); | ||
sinon.assert.calledOnce(spy); | ||
sinon.assert.calledWithExactly(spy, req); | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters