From 244650835e82e7e7a8c13ca6d71c131cb0d727cc Mon Sep 17 00:00:00 2001 From: Seyaji <67058118+Seyaji@users.noreply.github.com> Date: Sat, 18 Jun 2022 11:13:51 +0100 Subject: [PATCH] Refactor 'Basic Settings' test to RTL from Enzyme (#51059) * Refactor 'Basic Settings' test to RTL from Enzyme * Update public/app/features/datasources/settings/BasicSettings.test.tsx Co-authored-by: Alex Khomenko * Refactor 'Basic Settings' test to RTL from Enzyme Co-authored-by: Alex Khomenko --- .betterer.results | 3 -- .../settings/BasicSettings.test.tsx | 13 +++--- .../__snapshots__/BasicSettings.test.tsx.snap | 43 ------------------- 3 files changed, 8 insertions(+), 51 deletions(-) delete mode 100644 public/app/features/datasources/settings/__snapshots__/BasicSettings.test.tsx.snap diff --git a/.betterer.results b/.betterer.results index e8f68744fd2..d915d1eeae9 100644 --- a/.betterer.results +++ b/.betterer.results @@ -125,9 +125,6 @@ exports[`no enzyme tests`] = { "public/app/features/datasources/DataSourcesListPage.test.tsx:2960099202": [ [0, 19, 13, "RegExp match", "2409514259"] ], - "public/app/features/datasources/settings/BasicSettings.test.tsx:625016324": [ - [0, 19, 13, "RegExp match", "2409514259"] - ], "public/app/features/datasources/settings/ButtonRow.test.tsx:1422996720": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/public/app/features/datasources/settings/BasicSettings.test.tsx b/public/app/features/datasources/settings/BasicSettings.test.tsx index 389c6618fcc..0f58cf241f4 100644 --- a/public/app/features/datasources/settings/BasicSettings.test.tsx +++ b/public/app/features/datasources/settings/BasicSettings.test.tsx @@ -1,6 +1,8 @@ -import { shallow } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; +import { selectors } from '@grafana/e2e-selectors'; + import BasicSettings, { Props } from './BasicSettings'; const setup = () => { @@ -11,13 +13,14 @@ const setup = () => { onNameChange: jest.fn(), }; - return shallow(); + return render(); }; -describe('Render', () => { +describe('Basic Settings', () => { it('should render component', () => { - const wrapper = setup(); + setup(); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByRole('textbox', { name: selectors.pages.DataSource.name })).toBeInTheDocument(); + expect(screen.getByRole('checkbox', { name: 'Default' })).toBeInTheDocument(); }); }); diff --git a/public/app/features/datasources/settings/__snapshots__/BasicSettings.test.tsx.snap b/public/app/features/datasources/settings/__snapshots__/BasicSettings.test.tsx.snap deleted file mode 100644 index e1d5f3203d3..00000000000 --- a/public/app/features/datasources/settings/__snapshots__/BasicSettings.test.tsx.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Render should render component 1`] = ` -
-
-
- - - -
- - - -
-
-`;