Convert NamedColorsPalette tests to RTL (#49064)

This commit is contained in:
Ashley Harrison 2022-05-17 11:34:15 +01:00 committed by GitHub
parent d477394d6c
commit 3b0cd8b6f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 14 deletions

View File

@ -8,9 +8,6 @@ exports[`no enzyme tests`] = {
"packages/grafana-ui/src/components/BarGauge/BarGauge.test.tsx:4199795290": [
[0, 19, 13, "RegExp match", "2409514259"]
],
"packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.test.tsx:3311646309": [
[0, 31, 13, "RegExp match", "2409514259"]
],
"packages/grafana-ui/src/components/FormField/FormField.test.tsx:3429087660": [
[0, 19, 13, "RegExp match", "2409514259"]
],

View File

@ -1,9 +1,8 @@
import { mount, ReactWrapper } from 'enzyme';
import { screen, render } from '@testing-library/react';
import React from 'react';
import { createTheme } from '@grafana/data';
import { ColorSwatch } from './ColorSwatch';
import { NamedColorsPalette } from './NamedColorsPalette';
describe('NamedColorsPalette', () => {
@ -12,16 +11,9 @@ describe('NamedColorsPalette', () => {
const selectedShade = greenHue.shades[2];
describe('theme support for named colors', () => {
let wrapper: ReactWrapper, selectedSwatch;
afterEach(() => {
wrapper.unmount();
});
it('should render provided color variant specific for theme', () => {
wrapper = mount(<NamedColorsPalette color={selectedShade.name} onChange={() => {}} />);
selectedSwatch = wrapper.find(ColorSwatch).findWhere((node) => node.key() === selectedShade.name);
expect(selectedSwatch.prop('color')).toBe(selectedShade.color);
render(<NamedColorsPalette color={selectedShade.name} onChange={jest.fn()} />);
expect(screen.getByRole('button', { name: `${selectedShade.name} color` })).toBeInTheDocument();
});
});
});