Add utils

This commit is contained in:
Jeremy Thomas 2021-11-12 22:59:02 +00:00
parent 41e28cff8a
commit 2a4ba6becd
4 changed files with 48 additions and 32 deletions

View File

@ -1,3 +1,5 @@
import { setMobile, setDesktop } from "../utils";
describe("Components/Navbar", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/navbar/");
@ -125,10 +127,7 @@ describe("Components/Navbar", () => {
describe("Components/Navbar Mobile", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/navbar/");
cy.viewport(
Cypress.env("viewports").mobile[0],
Cypress.env("viewports").mobile[1]
);
setMobile();
});
it("has a Navbar", () => {
@ -182,10 +181,7 @@ describe("Components/Navbar Mobile", () => {
describe("Components/Navbar Desktop", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/navbar/");
cy.viewport(
Cypress.env("viewports").desktop[0],
Cypress.env("viewports").desktop[1]
);
setDesktop();
});
it("has a Navbar", () => {

View File

@ -1,3 +1,5 @@
import { setMobile, setTablet } from "../utils";
describe("Components/Pagination", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/pagination/");
@ -79,10 +81,7 @@ describe("Components/Pagination", () => {
describe("Components/Pagination Mobile", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/pagination/");
cy.viewport(
Cypress.env("viewports").mobile[0],
Cypress.env("viewports").mobile[1]
);
setMobile();
});
it("has a correct Pagination", () => {
@ -113,10 +112,7 @@ describe("Components/Pagination Mobile", () => {
describe("Components/Navbar Tablet", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/pagination/");
cy.viewport(
Cypress.env("viewports").tablet[0],
Cypress.env("viewports").tablet[1]
);
setTablet();
});
it("has a correct Pagination", () => {

View File

@ -1,3 +1,5 @@
import { setMobile, setDesktop } from "../utils";
describe("Elements/Container", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/elements/container/");
@ -8,10 +10,7 @@ describe("Elements/Container", () => {
});
it("has fullwidth mobile Containers", () => {
cy.viewport(
Cypress.env("viewports").mobile[0],
Cypress.env("viewports").mobile[1]
);
setMobile();
let viewport;
@ -45,10 +44,7 @@ describe("Elements/Container", () => {
});
it("has centered desktop Containers", () => {
cy.viewport(
Cypress.env("viewports").desktop[0],
Cypress.env("viewports").desktop[1]
);
setDesktop();
let viewport;
@ -77,10 +73,7 @@ describe("Elements/Container", () => {
});
it("has centered widescreen Containers", () => {
cy.viewport(
Cypress.env("viewports").widescreen[0],
Cypress.env("viewports").widescreen[1]
);
setWidescreen();
let viewport;
@ -114,10 +107,7 @@ describe("Elements/Container", () => {
});
it("has centered fullhd Containers", () => {
cy.viewport(
Cypress.env("viewports").fullhd[0],
Cypress.env("viewports").fullhd[1]
);
setFullHD();
cy.get("#container").then(($) => {
const cs = window.getComputedStyle($[0]);

View File

@ -0,0 +1,34 @@
export const setMobile = () => {
cy.viewport(
Cypress.env("viewports").mobile[0],
Cypress.env("viewports").mobile[1]
);
};
export const setTablet = () => {
cy.viewport(
Cypress.env("viewports").tablet[0],
Cypress.env("viewports").tablet[1]
);
};
export const setDesktop = () => {
cy.viewport(
Cypress.env("viewports").desktop[0],
Cypress.env("viewports").desktop[1]
);
};
export const setWidescreen = () => {
cy.viewport(
Cypress.env("viewports").widescreen[0],
Cypress.env("viewports").widescreen[1]
);
};
export const setFullHD = () => {
cy.viewport(
Cypress.env("viewports").fullhd[0],
Cypress.env("viewports").fullhd[1]
);
};