Chore: Upgrades jQuery and @types/jQuery (#25651)

* Chore: upgrades jQuery and @types/jQuery

* Chore: reduce strict null errors

* Fixed issue in graphite func editor

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Hugo Häggmark
2020-06-18 11:35:11 +02:00
committed by GitHub
parent eb792490d6
commit e2ba0731e2
29 changed files with 84 additions and 70 deletions

View File

@@ -18,9 +18,12 @@ describe('DataLinks', () => {
it('renders correctly when no fields', async () => {
let wrapper: any;
await act(async () => {
wrapper = await mount(<DataLinks onChange={() => {}} />);
});
await act(
// @ts-ignore we shouldn't use Promises in act => the "void | undefined" is here to forbid any sneaky "Promise" returns.
async () => {
wrapper = await mount(<DataLinks onChange={() => {}} />);
}
);
expect(wrapper.find(Button).length).toBe(1);
expect(wrapper.find(Button).contains('Add')).toBeTruthy();
expect(wrapper.find(DataLink).length).toBe(0);
@@ -28,9 +31,12 @@ describe('DataLinks', () => {
it('renders correctly when there are fields', async () => {
let wrapper: any;
await act(async () => {
wrapper = await mount(<DataLinks value={testValue} onChange={() => {}} />);
});
await act(
// @ts-ignore we shouldn't use Promises in act => the "void | undefined" is here to forbid any sneaky "Promise" returns.
async () => {
wrapper = await mount(<DataLinks value={testValue} onChange={() => {}} />);
}
);
expect(wrapper.find(Button).filterWhere((button: any) => button.contains('Add')).length).toBe(1);
expect(wrapper.find(DataLink).length).toBe(2);
@@ -39,9 +45,12 @@ describe('DataLinks', () => {
it('adds new field', async () => {
const onChangeMock = jest.fn();
let wrapper: any;
await act(async () => {
wrapper = await mount(<DataLinks onChange={onChangeMock} />);
});
await act(
// @ts-ignore we shouldn't use Promises in act => the "void | undefined" is here to forbid any sneaky "Promise" returns.
async () => {
wrapper = await mount(<DataLinks onChange={onChangeMock} />);
}
);
const addButton = wrapper.find(Button).filterWhere((button: any) => button.contains('Add'));
addButton.simulate('click');
expect(onChangeMock.mock.calls[0][0].length).toBe(1);
@@ -50,9 +59,12 @@ describe('DataLinks', () => {
it('removes field', async () => {
const onChangeMock = jest.fn();
let wrapper: any;
await act(async () => {
wrapper = await mount(<DataLinks value={testValue} onChange={onChangeMock} />);
});
await act(
// @ts-ignore we shouldn't use Promises in act => the "void | undefined" is here to forbid any sneaky "Promise" returns.
async () => {
wrapper = await mount(<DataLinks value={testValue} onChange={onChangeMock} />);
}
);
const removeButton = wrapper
.find(DataLink)
.at(0)

View File

@@ -1,18 +1,16 @@
import angular from 'angular';
import { CoreApp, DataQueryRequest, dateMath, Field } from '@grafana/data';
import { CoreApp, DataQueryRequest, DataSourceInstanceSettings, dateMath, dateTime, Field, toUtc } from '@grafana/data';
import _ from 'lodash';
import { ElasticDatasource } from './datasource';
import { toUtc, dateTime } from '@grafana/data';
import { backendSrv } from 'app/core/services/backend_srv'; // will use the version in __mocks__
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { DataSourceInstanceSettings } from '@grafana/data';
import { ElasticsearchOptions, ElasticsearchQuery } from './types';
const ELASTICSEARCH_MOCK_URL = 'http://elasticsearch.local';
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
...((jest.requireActual('@grafana/runtime') as unknown) as object),
getBackendSrv: () => backendSrv,
}));