-
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.
- Loading branch information
1 parent
e16dc13
commit 5d259b9
Showing
3 changed files
with
103 additions
and
47 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/plugins/vis_type_timelion/public/helpers/timelion_request_handler.test.ts
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,54 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import moment from 'moment'; | ||
import { coreMock } from '../../../../core/public/mocks'; | ||
import { dataPluginMock } from '../../../data/public/mocks'; | ||
import { getTimelionRequestHandler } from './timelion_request_handler'; | ||
|
||
describe('Timelion request handler', function () { | ||
const core = coreMock.createStart(); | ||
const data = dataPluginMock.createStartContract(); | ||
let timelionRequestHandler: any; | ||
|
||
beforeEach(function () { | ||
core.http.post | ||
.mockReturnValueOnce(Promise.resolve({ sheet: [{ is_running: true }] })) | ||
.mockReturnValueOnce(Promise.resolve({ sheet: [{ is_running: false }] })); | ||
|
||
data.query.timefilter.timefilter.calculateBounds = () => { | ||
return { min: moment(), max: moment() }; | ||
}; | ||
timelionRequestHandler = getTimelionRequestHandler({ | ||
uiSettings: core.uiSettings, | ||
http: core.http, | ||
timefilter: data.query.timefilter.timefilter, | ||
}); | ||
}); | ||
|
||
it('checking polling', async function () { | ||
await timelionRequestHandler({ | ||
timeRange: {}, | ||
filters: [], | ||
query: { query: 'es' }, | ||
visParams: { expression: 'es' }, | ||
}); | ||
expect(core.http.post).toHaveBeenCalledTimes(2); | ||
}); | ||
}); |
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