Skip to content

Commit

Permalink
Merge pull request #178 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Develop - MainProductsTesting +80%
  • Loading branch information
sebaslh01 authored May 2, 2022
2 parents 2d39821 + f72c654 commit b710f39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion webapp/src/components/products/MainProducts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function MainProducts(props: MainProductsProps): JSX.Element {
label="color-filter"
>
<MenuItem>
<ListItem button key="all" onClick={() => { filterColor("All") }}>
<ListItem button data-testid="all-color" key="all" onClick={() => { filterColor("All") }}>
<ListItemIcon>
<ListItemText primary="All" />
</ListItemIcon>
Expand Down
8 changes: 7 additions & 1 deletion webapp/src/components/products/tests/MainProducts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ test("When listing products, use filter by color black works", async () => {

//we cannot expect to see the content changed to red cars as we're mocking the API call..
expect(getByColorBlack).toHaveBeenCalledWith("&color[eq]=black");

let allOpt = screen.getByTestId("all-color");
fireEvent.click(allOpt);
expect(getByColorBlack).toHaveBeenCalledWith("");
});

test("When listing products, use filter by brand works as expected", async () => {
Expand Down Expand Up @@ -383,6 +385,10 @@ test("When listing products, use filter by brand works as expected", async () =>
//we cannot expect to see the content changed to Toyota cars as we're mocking the API call..
//thus, we can only test the parameters passed to the API
expect(getByBrand).toHaveBeenCalledWith("&brand[eq]=Toyota");

let allOpt = screen.getByTestId("All");
fireEvent.click(allOpt);
expect(getByBrand).toHaveBeenCalledWith("");
});

test("When listing products, use filter by rating works as expected", async () => {
Expand Down

0 comments on commit b710f39

Please sign in to comment.