-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't assume that desiredSize will always be set
Fixes #5642
- Loading branch information
Showing
2 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/ui/public/courier/fetch/request/__tests__/segmented_size_picking.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,55 @@ | ||
import ngMock from 'ngMock'; | ||
import expect from 'expect.js'; | ||
import { times } from 'lodash'; | ||
import sinon from 'auto-release-sinon'; | ||
|
||
import HitSortFnProv from 'plugins/kibana/discover/_hit_sort_fn'; | ||
import NoDigestPromises from 'testUtils/noDigestPromises'; | ||
|
||
describe('Segmented Request Size Picking', function () { | ||
let Promise; | ||
let $rootScope; | ||
let SegmentedReq; | ||
let MockSource; | ||
let HitSortFn; | ||
|
||
NoDigestPromises.activateForSuite(); | ||
|
||
beforeEach(ngMock.module('kibana')); | ||
beforeEach(ngMock.inject((Private, $injector) => { | ||
Promise = $injector.get('Promise'); | ||
HitSortFn = Private(HitSortFnProv); | ||
$rootScope = $injector.get('$rootScope'); | ||
SegmentedReq = Private(require('ui/courier/fetch/request/segmented')); | ||
|
||
const StubbedSearchSourceProvider = require('fixtures/stubbed_search_source'); | ||
MockSource = class { | ||
constructor() { | ||
return $injector.invoke(StubbedSearchSourceProvider); | ||
} | ||
}; | ||
})); | ||
|
||
context('without a size', function () { | ||
it('does not set the request size', async function () { | ||
const req = new SegmentedReq(new MockSource()); | ||
req._handle.setDirection('desc'); | ||
req._handle.setSortFn(new HitSortFn('desc')); | ||
await req.start(); | ||
|
||
expect((await req.getFetchParams()).body).to.not.have.property('size'); | ||
}); | ||
}); | ||
|
||
context('with a size', function () { | ||
it('sets the request size to the entire desired size', async function () { | ||
const req = new SegmentedReq(new MockSource()); | ||
req._handle.setDirection('desc'); | ||
req._handle.setSize(555); | ||
req._handle.setSortFn(new HitSortFn('desc')); | ||
await req.start(); | ||
|
||
expect((await req.getFetchParams()).body).to.have.property('size', 555); | ||
}); | ||
}); | ||
}); |
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