Skip to content

Commit

Permalink
Add test to button favorite
Browse files Browse the repository at this point in the history
$ yarn run start:storybook:test

Test for the following
- Material id is not on user's favorites list
- Material id is on user's favorites list
- User can add and remove material id from favorite list
  • Loading branch information
kasperbirch1 committed Jun 20, 2022
1 parent b818dda commit 7a84bfa
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/button-favourite/button-favourite.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
describe("Favorite button", () => {
it("Material id is not on user's favorites list", () => {
cy.intercept("HEAD", "**/list/default/**", {
statusCode: 404,
body: {}
});
cy.visit(
"/iframe.html?args=&id=components-button-favourite--favourite&viewMode=story"
);
cy.get('[aria-label="Tilføj til favoritter"]');
});

it("Material id is on user's favorites list", () => {
cy.intercept("HEAD", "**/list/default/**", {
statusCode: 200,
body: {}
});
cy.visit(
"/iframe.html?args=&id=components-button-favourite--favourite&viewMode=story"
);
cy.get('[aria-label="Fjern fra favoritter"]');
});

it("User can add and remove material id from favorite list", () => {
cy.intercept("HEAD", "**/list/default/**", {
statusCode: 404,
body: {}
});
cy.intercept("PUT", "**/list/default/**", {
statusCode: 201,
body: {}
});
cy.intercept("DELETE", "**/list/default/**", {
statusCode: 204,
body: {}
});
cy.visit(
"/iframe.html?args=&id=components-button-favourite--favourite&viewMode=story"
);
cy.get('[aria-label="Tilføj til favoritter"]').click();
cy.get('[aria-label="Fjern fra favoritter"]').click();
cy.get('[aria-label="Tilføj til favoritter"]').click();
});
});

export {};

0 comments on commit 7a84bfa

Please sign in to comment.