mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Converts ButtonRow tests to RTL (#51068)
This commit is contained in:
parent
e4f4cc4a32
commit
606732dd5e
@ -122,9 +122,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/datasources/DataSourcesListPage.test.tsx:2960099202": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/datasources/settings/ButtonRow.test.tsx:1422996720": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx:4164297658": [
|
||||
[0, 17, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { screen, render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
|
||||
import ButtonRow, { Props } from './ButtonRow';
|
||||
|
||||
jest.mock('app/core/core', () => {
|
||||
@ -23,22 +25,18 @@ const setup = (propOverrides?: object) => {
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
return shallow(<ButtonRow {...props} />);
|
||||
return render(<ButtonRow {...props} />);
|
||||
};
|
||||
|
||||
describe('Render', () => {
|
||||
describe('Button Row', () => {
|
||||
it('should render component', () => {
|
||||
const wrapper = setup();
|
||||
setup();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(screen.getByRole('button', { name: selectors.pages.DataSource.delete })).toBeInTheDocument();
|
||||
});
|
||||
it('should render save & test', () => {
|
||||
setup({ canSave: true });
|
||||
|
||||
it('should render with buttons enabled', () => {
|
||||
const wrapper = setup({
|
||||
canSave: true,
|
||||
canDelete: true,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(screen.getByRole('button', { name: selectors.pages.DataSource.saveAndTest })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -1,81 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<div
|
||||
className="gf-form-button-row"
|
||||
>
|
||||
<Button
|
||||
fill="solid"
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
>
|
||||
Back
|
||||
</Button>
|
||||
<LinkButton
|
||||
disabled={false}
|
||||
fill="solid"
|
||||
href="/explore"
|
||||
variant="secondary"
|
||||
>
|
||||
Explore
|
||||
</LinkButton>
|
||||
<Button
|
||||
aria-label="Data source settings page Delete button"
|
||||
disabled={true}
|
||||
onClick={[MockFunction]}
|
||||
type="button"
|
||||
variant="destructive"
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
<Button
|
||||
onClick={[MockFunction]}
|
||||
type="submit"
|
||||
variant="primary"
|
||||
>
|
||||
Test
|
||||
</Button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Render should render with buttons enabled 1`] = `
|
||||
<div
|
||||
className="gf-form-button-row"
|
||||
>
|
||||
<Button
|
||||
fill="solid"
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
>
|
||||
Back
|
||||
</Button>
|
||||
<LinkButton
|
||||
disabled={false}
|
||||
fill="solid"
|
||||
href="/explore"
|
||||
variant="secondary"
|
||||
>
|
||||
Explore
|
||||
</LinkButton>
|
||||
<Button
|
||||
aria-label="Data source settings page Delete button"
|
||||
disabled={false}
|
||||
onClick={[MockFunction]}
|
||||
type="button"
|
||||
variant="destructive"
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
<Button
|
||||
aria-label="Data source settings page Save and Test button"
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="submit"
|
||||
variant="primary"
|
||||
>
|
||||
Save & test
|
||||
</Button>
|
||||
</div>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user