mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Upgrade Jest to latest (#25591)
* Chore: Upgrade Jest to latest Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Chore: reduces strict null errors Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { QueryOperationRow } from './QueryOperationRow';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
describe('QueryOperationRow', () => {
|
||||
@@ -17,6 +17,7 @@ describe('QueryOperationRow', () => {
|
||||
describe('callbacks', () => {
|
||||
it('should not call onOpen when component is shallowed', async () => {
|
||||
const onOpenSpy = jest.fn();
|
||||
// @ts-ignore strict null error, you shouldn't use promise like approach with act but I don't know what the intention is here
|
||||
await act(async () => {
|
||||
shallow(
|
||||
<QueryOperationRow onOpen={onOpenSpy}>
|
||||
@@ -38,10 +39,13 @@ describe('QueryOperationRow', () => {
|
||||
const titleEl = wrapper.find({ 'aria-label': 'Query operation row title' });
|
||||
expect(titleEl).toHaveLength(1);
|
||||
|
||||
// @ts-ignore strict null error, you shouldn't use promise like approach with act but I don't know what the intention is here
|
||||
await act(async () => {
|
||||
// open
|
||||
titleEl.first().simulate('click');
|
||||
});
|
||||
|
||||
// @ts-ignore strict null error, you shouldn't use promise like approach with act but I don't know what the intention is here
|
||||
await act(async () => {
|
||||
// close
|
||||
titleEl.first().simulate('click');
|
||||
|
@@ -2,6 +2,8 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { MetricSelect } from './MetricSelect';
|
||||
import { LegacyForms } from '@grafana/ui';
|
||||
import { expect } from '../../../../test/lib/common';
|
||||
|
||||
const { Select } = LegacyForms;
|
||||
|
||||
describe('MetricSelect', () => {
|
||||
@@ -32,16 +34,15 @@ describe('MetricSelect', () => {
|
||||
variables: [],
|
||||
};
|
||||
const wrapper = shallow(<MetricSelect {...props} />);
|
||||
wrapper
|
||||
.find(Select)
|
||||
.props()
|
||||
.onChange({ value: 'foo' });
|
||||
expect(
|
||||
wrapper
|
||||
.find(Select)
|
||||
.props()
|
||||
.noOptionsMessage()
|
||||
).toEqual('No options found');
|
||||
const select = wrapper.find(Select);
|
||||
|
||||
select.props().onChange({ value: 'foo' });
|
||||
|
||||
expect(select.props().noOptionsMessage).toBeDefined();
|
||||
|
||||
// @ts-ignore typescript doesn't understand that noOptionsMessage can't be undefined here
|
||||
const noOptionsMessage = select.props().noOptionsMessage();
|
||||
expect(noOptionsMessage).toEqual('No options found');
|
||||
expect(spyOnChange).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user