Chore: convert Cloud Monitoring Aggregation enzyme tests to RTL (#50326)

This commit is contained in:
Kevin Yu 2022-06-08 01:03:58 -07:00 committed by GitHub
parent 50145e1617
commit 8bd56b8226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 20 deletions

View File

@ -158,9 +158,6 @@ exports[`no enzyme tests`] = {
"public/app/features/users/UsersListPage.test.tsx:2518052139": [
[0, 19, 13, "RegExp match", "2409514259"]
],
"public/app/plugins/datasource/cloud-monitoring/components/Aggregation.test.tsx:3822406835": [
[1, 19, 13, "RegExp match", "2409514259"]
],
"public/app/plugins/datasource/cloudwatch/components/ConfigEditor.test.tsx:227258837": [
[0, 19, 13, "RegExp match", "2409514259"]
],

View File

@ -1,10 +1,8 @@
import { render, screen } from '@testing-library/react';
import { shallow } from 'enzyme';
import React from 'react';
import { openMenu } from 'react-select-event';
import { TemplateSrvStub } from 'test/specs/helpers';
import { Select } from '@grafana/ui';
import { ValueTypes, MetricKind } from '../types';
import { Aggregation, Props } from './Aggregation';
@ -39,14 +37,11 @@ describe('Aggregation', () => {
};
it('should not have the reduce values', () => {
const wrapper = shallow(<Aggregation {...nextProps} />);
const { options } = wrapper.find(Select).props() as any;
const [, aggGroup] = options;
expect(aggGroup.options.length).toEqual(11);
expect(aggGroup.options.map((o: any) => o.value)).toEqual(
expect.not.arrayContaining(['REDUCE_COUNT_TRUE', 'REDUCE_COUNT_FALSE'])
);
render(<Aggregation {...nextProps} />);
const label = screen.getByLabelText('Group by function');
openMenu(label);
expect(screen.queryByText('count true')).not.toBeInTheDocument();
expect(screen.queryByText('count false')).not.toBeInTheDocument();
});
});
@ -60,12 +55,10 @@ describe('Aggregation', () => {
};
it('should have the reduce values', () => {
const wrapper = shallow(<Aggregation {...nextProps} />);
const { options } = wrapper.find(Select).props() as any;
const [, aggGroup] = options;
expect(aggGroup.options.length).toEqual(11);
expect(aggGroup.options.map((o: any) => o.value)).toEqual(expect.arrayContaining(['REDUCE_NONE']));
render(<Aggregation {...nextProps} />);
const label = screen.getByLabelText('Group by function');
openMenu(label);
expect(screen.getByText('none')).toBeInTheDocument();
});
});
});