Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vis/requesting] only call when actually requesting (#14017)
* [vis/requesting] only call when actually requesting * [courier/dataSource] use Promise.map to catch sync errors * [courier/request] move source mutation logic out of request (cherry picked from commit b0dc246)
- Loading branch information
Showing
9 changed files
with
147 additions
and
39 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
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
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