Skip to content

Commit

Permalink
[test] Migrate NewWindowIcon.test.js from Enzyme to RTL (#1701)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- This PR migrates the test `NewWindowIcon.test.js` from Enzyme to RTL
- part of: #1668

## How was this change tested?
- using `yarn test-ci`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Ansh Goyal <[email protected]>
  • Loading branch information
anshgoyalevil authored Aug 20, 2023
1 parent 7507262 commit 9d60e95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
28 changes: 15 additions & 13 deletions packages/jaeger-ui/src/components/common/NewWindowIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@
// limitations under the License.

import React from 'react';
import { shallow } from 'enzyme';

import { render } from '@testing-library/react';
import '@testing-library/jest-dom/';
import NewWindowIcon from './NewWindowIcon';

describe('NewWindowIcon', () => {
const props = {
notIsLarge: 'not is large',
};
let wrapper;

beforeEach(() => {
wrapper = shallow(<NewWindowIcon {...props} />);
});

it('renders as expected', () => {
expect(wrapper).toMatchSnapshot();
it('renders without is-large className when props.isLarge is false', () => {
const { container } = render(<NewWindowIcon {...props} />);
expect(container.querySelector('.is-large')).toBeNull();
});

it('adds is-large className when props.isLarge is true', () => {
expect(wrapper.hasClass('is-large')).toBe(false);
wrapper.setProps({ isLarge: true });
expect(wrapper.hasClass('is-large')).toBe(true);
const { rerender, container } = render(<NewWindowIcon {...props} />);

// Initial render, is-large should be false
expect(container.querySelector('.is-large')).toBeNull();

// Re-render with isLarge prop set to true
rerender(<NewWindowIcon {...props} isLarge />);

// After re-render, is-large should be true
expect(container.querySelector('.is-large')).toBeInTheDocument();
});
});

This file was deleted.

0 comments on commit 9d60e95

Please sign in to comment.