Chore: Convert pageActionBar test to RTL (#51073)

* Convert pageActionBar test to RTL

* add test for conditional render of button
pull/50850/head^2
Seyaji 3 years ago committed by GitHub
parent 3a586a6053
commit e4f4cc4a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .betterer.results
  2. 15
      public/app/core/components/PageActionBar/PageActionBar.test.tsx
  3. 23
      public/app/core/components/PageActionBar/__snapshots__/PageActionBar.test.tsx.snap

@ -92,9 +92,6 @@ exports[`no enzyme tests`] = {
"packages/jaeger-ui-components/src/TraceTimelineViewer/index.test.js:276996587": [
[14, 19, 13, "RegExp match", "2409514259"]
],
"public/app/core/components/PageActionBar/PageActionBar.test.tsx:1251504193": [
[0, 19, 13, "RegExp match", "2409514259"]
],
"public/app/core/components/QueryOperationRow/QueryOperationAction.test.tsx:3032694716": [
[0, 19, 13, "RegExp match", "2409514259"]
],

@ -1,4 +1,4 @@
import { shallow } from 'enzyme';
import { render, screen } from '@testing-library/react';
import React from 'react';
import PageActionBar, { Props } from './PageActionBar';
@ -13,13 +13,20 @@ const setup = (propOverrides?: object) => {
Object.assign(props, propOverrides);
return shallow(<PageActionBar {...props} />);
return render(<PageActionBar {...props} />);
};
describe('Render', () => {
it('should render component', () => {
const wrapper = setup();
setup();
expect(wrapper).toMatchSnapshot();
expect(screen.getByRole('textbox')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'test' })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Clear' })).not.toBeInTheDocument();
});
it('should render button when text is present', () => {
setup({ searchQuery: 'test query' });
expect(screen.getByRole('button', { name: 'Clear' })).toBeInTheDocument();
});
});

@ -1,23 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should render component 1`] = `
<div
className="page-action-bar"
>
<div
className="gf-form gf-form--grow"
>
<FilterInput
onChange={[MockFunction]}
placeholder="Search by name or type"
value=""
/>
</div>
<LinkButton
href="some/url"
target="_blank"
>
test
</LinkButton>
</div>
`;
Loading…
Cancel
Save