Skip to content

Commit

Permalink
test: follow mike request - replace data-testid for querySelector by …
Browse files Browse the repository at this point in the history
…classes on file Search.jsx
  • Loading branch information
wrspada02 committed Sep 30, 2024
1 parent 7f2b1ec commit 65cd50f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
14 changes: 3 additions & 11 deletions app/assets/javascripts/components/search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import Stories from '../stories/Stories';
import * as Story from '../../models/beta/story';

export const SearchHeader = ({ stories }) => (
<div
className="Sprint__header"
data-id="search-header"
data-testid="search-header-container"
>
<div className="Sprint__header" data-id="search-header">
{I18n.t('stories_found')}: {stories.length}
<div>
<span className="done-points">
Expand All @@ -19,13 +15,9 @@ export const SearchHeader = ({ stories }) => (
);

const Search = ({ stories }) => (
<div className="Sprint" data-testid="sprint-container">
<div className="Sprint">
<SearchHeader stories={stories} />
<div
className="Sprint__body"
data-id="stories-search"
data-testid="stories-search-container"
>
<div className="Sprint__body" data-id="stories-search">
<Stories
columnId="search"
stories={stories}
Expand Down
8 changes: 4 additions & 4 deletions spec/javascripts/components/search/search_results_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ describe('<SearchResults />', () => {

describe('when isEnabled is false', () => {
it('does not render the component', () => {
const { queryByTestId } = renderComponent();
const { container } = renderComponent();

expect(queryByTestId('sprint-container')).not.toBeInTheDocument();
expect(container.querySelector('.Sprint')).not.toBeInTheDocument();
});
});

describe('when isEnabled is true', () => {
it('renders the component', () => {
const { getByTestId } = renderComponent({ isEnabled: true });
const { container } = renderComponent({ isEnabled: true });

expect(getByTestId('sprint-container')).toBeInTheDocument();
expect(container.querySelector('.Sprint')).toBeInTheDocument();
});
});
});
18 changes: 9 additions & 9 deletions spec/javascripts/components/search/search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ describe('<Search />', () => {
});

it('renders header', () => {
const { getByTestId } = renderComponent();
const { container } = renderComponent();

expect(getByTestId('search-header-container')).toBeInTheDocument();
expect(container.querySelector('.Sprint__header')).toBeInTheDocument();
});

it('renders stories', () => {
const { getByTestId } = renderComponent();
const { container } = renderComponent();

expect(getByTestId('search-header-container')).toBeInTheDocument();
expect(getByTestId('stories-search-container')).toBeInTheDocument();
expect(container.querySelector('.Sprint__header')).toBeInTheDocument();
expect(container.querySelector('.Sprint__body')).toBeInTheDocument();
});
});

Expand All @@ -65,15 +65,15 @@ describe('<Search />', () => {
});

it('renders header', () => {
const { getByTestId } = renderComponent();
const { container } = renderComponent();

expect(getByTestId('search-header-container')).toBeInTheDocument();
expect(container.querySelector('.Sprint__header')).toBeInTheDocument();
});

it('renders stories', () => {
const { getByTestId } = renderComponent();
const { container } = renderComponent();

expect(getByTestId('stories-search-container')).toBeInTheDocument();
expect(container.querySelector('.Sprint__body')).toBeInTheDocument();
});
});
});

0 comments on commit 65cd50f

Please sign in to comment.