Skip to content

Commit

Permalink
test: test remove search tag from list, remove 'button' from SearchTag
Browse files Browse the repository at this point in the history
  • Loading branch information
awenine committed Jan 23, 2021
1 parent b6dcddc commit e627b44
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/techlog/src/Components/Search/SearchTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const SearchTags = ({tag, deleteTagHandler}) => {

return (
<div className="searchtag__frag">
<li className="searchtag__tag">#{tag}</li>
<button className="searchtag__btn" onClick={deleteTagHandler}></button>
<li className="searchtag__tag" onClick={deleteTagHandler}>#{tag}</li>
{/* <button className="searchtag__btn" onClick={deleteTagHandler}></button> */}
</div>
)
}
Expand Down
27 changes: 25 additions & 2 deletions client/techlog/src/__tests__/SearchReport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,30 @@ describe('Search Reports', () => {

});




it('Should remove a tag when clicked on', async () => {
const dummyReports = [];

jest.spyOn(window, "fetch").mockImplementation(() =>
Promise.resolve({
json: () => Promise.resolve(dummyReports)
})
);

await act(async () => {
render(<MemoryRouter><SearchList/></MemoryRouter>);
});

const testTag = 'testTag';
fireEvent.change(screen.getByRole('textbox'), {
target: { value: testTag }
});
fireEvent.click(screen.getByRole('button', {name: 'ADD TAG'}));
const renderedTag = screen.getByText(/testTag/i);
fireEvent.click(renderedTag);
expect(renderedTag).not.toBeInTheDocument();

});

});

0 comments on commit e627b44

Please sign in to comment.