From 7e5ea3f5a0ac569b89bc1e2dcf9ceb8d001c0635 Mon Sep 17 00:00:00 2001 From: Chrysa Dikonimaki Date: Wed, 11 May 2022 00:53:14 +0200 Subject: [PATCH] convert LogLabels tests toRTL (#48887) --- .betterer.results | 3 --- .../src/components/Logs/LogLabels.test.tsx | 26 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.betterer.results b/.betterer.results index 60dc1e11ac1..dabdf567604 100644 --- a/.betterer.results +++ b/.betterer.results @@ -26,9 +26,6 @@ exports[`no enzyme tests`] = { "packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.test.tsx:1865444105": [ [0, 17, 13, "RegExp match", "2409514259"] ], - "packages/grafana-ui/src/components/Logs/LogLabels.test.tsx:1029448019": [ - [0, 19, 13, "RegExp match", "2409514259"] - ], "packages/grafana-ui/src/components/Logs/LogMessageAnsi.test.tsx:1630730648": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/packages/grafana-ui/src/components/Logs/LogLabels.test.tsx b/packages/grafana-ui/src/components/Logs/LogLabels.test.tsx index fc1a4f23120..e78be881867 100644 --- a/packages/grafana-ui/src/components/Logs/LogLabels.test.tsx +++ b/packages/grafana-ui/src/components/Logs/LogLabels.test.tsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import { getTheme } from '../../themes'; @@ -7,23 +7,23 @@ import { UnThemedLogLabels as LogLabels } from './LogLabels'; describe('', () => { it('renders notice when no labels are found', () => { - const wrapper = shallow(); - expect(wrapper.text()).toContain('no unique labels'); + render(); + expect(screen.queryByText('(no unique labels)')).toBeInTheDocument(); }); it('renders labels', () => { - const wrapper = shallow(); - expect(wrapper.text()).toContain('bar'); - expect(wrapper.text()).toContain('42'); + render(); + expect(screen.queryByText('bar')).toBeInTheDocument(); + expect(screen.queryByText('42')).toBeInTheDocument(); }); it('excludes labels with certain names or labels starting with underscore', () => { - const wrapper = shallow(); - expect(wrapper.text()).toContain('bar'); - expect(wrapper.text()).not.toContain('42'); - expect(wrapper.text()).not.toContain('13'); + render(); + expect(screen.queryByText('bar')).toBeInTheDocument(); + expect(screen.queryByText('42')).not.toBeInTheDocument(); + expect(screen.queryByText('13')).not.toBeInTheDocument(); }); it('excludes labels with empty string values', () => { - const wrapper = shallow(); - expect(wrapper.text()).toContain('bar'); - expect(wrapper.html()).not.toContain('baz'); + render(); + expect(screen.queryByText('bar')).toBeInTheDocument(); + expect(screen.queryByText('baz')).not.toBeInTheDocument(); }); });