bulma/docs/cypress/integration/elements/container.spec.js
Jeremy Thomas 0ce084170a
Setup cypress (#3436)
* Setup Cypress tests for box and button

* Add container tests

* Add Cypress workflow

* Use npm install

* Update Cypress workflow

* Add Jekyll build

* Test other action

* Test custom setup

* Use other ruby action

* Test without flag

* Move cypress to docs folder

* Record runs

* Add Content, Icon, Image specs

* Add Notification specs

* Add Progress and Table specs

* Add Tags specs

* Add Title specs

* Add breadcrumb specs

* Add more specs

* Add media specs

* Add menu specs

* Add modal specs

* Add navbar specs

* Add pagination specs

* Add panel specs

* Add tabs specs, Add form checkbox radio specs

* Add utils

* Add file specs

* Add input textarea specs

* Add select specs

* Add form tools specs

* Add other elements specs

* Add footer and hero specs

* Add Hero specs

* Add section specs

* Add grid specs

* Add column sizes specs

* Add tiles specs

* Add generic specs

* Fix generic tests

* Make font family test looser

* Remove system-ui test

* Remove important flag

* Fix disabled select color
2022-05-08 13:55:16 +01:00

160 lines
4.0 KiB
JavaScript

import { setMobile, setDesktop, setWidescreen, setFullHD } from "../utils";
describe("Elements/Container", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/elements/container/");
});
it("has a Container element", () => {
cy.get("#container").should("exist");
});
it("has fullwidth mobile Containers", () => {
setMobile();
let viewport;
cy.document()
.then((doc) => {
return doc.documentElement.getBoundingClientRect();
})
.then((rect) => {
viewport = rect;
});
cy.get("#container").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
cy.get("#container-fluid").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
cy.get("#container-max-desktop").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
cy.get("#container-max-widescreen").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
});
it("has centered desktop Containers", () => {
setDesktop();
let viewport;
cy.document()
.then((doc) => {
return doc.documentElement.getBoundingClientRect();
})
.then((rect) => {
viewport = rect;
});
cy.get("#container").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("960px");
});
cy.get("#container-widescreen").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
cy.get("#container-fullhd").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
});
it("has centered widescreen Containers", () => {
setWidescreen();
let viewport;
cy.document()
.then((doc) => {
return doc.documentElement.getBoundingClientRect();
})
.then((rect) => {
viewport = rect;
});
cy.get("#container").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1152px");
});
cy.get("#container-max-desktop").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("960px");
});
cy.get("#container-widescreen").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1152px");
});
cy.get("#container-fullhd").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
});
it("has centered fullhd Containers", () => {
setFullHD();
cy.get("#container").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1344px");
});
cy.get("#container-max-desktop").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("960px");
});
cy.get("#container-max-widescreen").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1152px");
});
cy.get("#container-widescreen").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1344px");
});
cy.get("#container-fullhd").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal("1344px");
});
});
it("has a fullwidth fluid Container", () => {
cy.viewport(
Cypress.env("viewports").fullhd[0],
Cypress.env("viewports").fullhd[1]
);
let viewport;
cy.document()
.then((doc) => {
return doc.documentElement.getBoundingClientRect();
})
.then((rect) => {
viewport = rect;
});
cy.get("#container-fluid").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.width).to.equal(`${viewport.width}px`);
});
});
});