Add breadcrumb specs

This commit is contained in:
Jeremy Thomas 2021-11-01 23:36:18 +00:00
parent 07f32233dd
commit 0ef5fced34
3 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,61 @@
---
layout: cypress
title: Components/Breadcrumb
---
{% capture content %}
<li><a href="#">Bulma</a></li>
<li><a href="#">Documentation</a></li>
<li><a href="#">Components</a></li>
<li class="is-active"><a href="#" aria-current="page">Breadcrumb</a></li>
{% endcapture %}
<nav id="breadcrumb" class="breadcrumb">
<ul>
{{ content }}
</ul>
</nav>
<nav id="breadcrumb-centered" class="breadcrumb is-centered">
<ul>
{{ content }}
</ul>
</nav>
<nav id="breadcrumb-right" class="breadcrumb is-right">
<ul>
{{ content }}
</ul>
</nav>
{% for size in site.data.sizes %}
<nav id="breadcrumb-{{ size }}" class="breadcrumb is-{{ size }}">
<ul>
{{ content }}
</ul>
</nav>
{% endfor %}
<nav id="breadcrumb-arrow" class="breadcrumb has-arrow-separator">
<ul>
{{ content }}
</ul>
</nav>
<nav id="breadcrumb-bullet" class="breadcrumb has-bullet-separator">
<ul>
{{ content }}
</ul>
</nav>
<nav id="breadcrumb-dot" class="breadcrumb has-dot-separator">
<ul>
{{ content }}
</ul>
</nav>
<nav id="breadcrumb-succeeds" class="breadcrumb has-succeeds-separator">
<ul>
{{ content }}
</ul>
</nav>

View File

@ -60,6 +60,7 @@
"scheme-main": "rgb(255, 255, 255)",
"border": "rgb(219, 219, 219)",
"border-hover": "rgb(181, 181, 181)",
"text": "rgb(74, 74, 74)",
"text-strong": "rgb(54, 54, 54)",

View File

@ -0,0 +1,98 @@
describe("Components/Breadcrumb", () => {
beforeEach(() => {
cy.visit("http://127.0.0.1:4000/cyp/components/breadcrumb/");
});
it("has a Breadcrumb", () => {
cy.get(".breadcrumb").should("exist");
});
it("has a correct Breadcrumb", () => {
cy.get("#breadcrumb").then(($) => {
const cs = window.getComputedStyle($[0]);
});
cy.get("#breadcrumb li:nth-child(2) a").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.color).to.equal(Cypress.env("link"));
expect(cs.padding).to.equal("0px 12px");
});
cy.get("#breadcrumb li.is-active a").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.color).to.equal(Cypress.env("text-strong"));
expect(cs.padding).to.equal("0px 12px");
});
});
it("has correct Breadcrumb alignments", () => {
cy.get("#breadcrumb-centered ul").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.justifyContent).to.equal("center");
});
cy.get("#breadcrumb-right ul").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.justifyContent).to.equal("flex-end");
});
});
it("has correct Breadcrumb sizes", () => {
cy.get("#breadcrumb-small").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.fontSize).to.equal(`${Cypress.env("sizes").small}px`);
});
cy.get("#breadcrumb-normal").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.fontSize).to.equal(`${Cypress.env("sizes").normal}px`);
});
cy.get("#breadcrumb-medium").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.fontSize).to.equal(`${Cypress.env("sizes").medium}px`);
});
cy.get("#breadcrumb-large").then(($) => {
const cs = window.getComputedStyle($[0]);
expect(cs.fontSize).to.equal(`${Cypress.env("sizes").large}px`);
});
});
it("has correct Breadcrumb separators", () => {
cy.get("#breadcrumb li:nth-child(2)").then(($) => {
const content = window
.getComputedStyle($[0], "before")
.getPropertyValue("content");
expect(content).to.equal('"/"');
});
cy.get("#breadcrumb-arrow li:nth-child(2)").then(($) => {
const content = window
.getComputedStyle($[0], "before")
.getPropertyValue("content");
expect(content).to.equal('"→"');
});
cy.get("#breadcrumb-bullet li:nth-child(2)").then(($) => {
const content = window
.getComputedStyle($[0], "before")
.getPropertyValue("content");
expect(content).to.equal('"•"');
});
cy.get("#breadcrumb-dot li:nth-child(2)").then(($) => {
const content = window
.getComputedStyle($[0], "before")
.getPropertyValue("content");
expect(content).to.equal('"·"');
});
cy.get("#breadcrumb-succeeds li:nth-child(2)").then(($) => {
const content = window
.getComputedStyle($[0], "before")
.getPropertyValue("content");
expect(content).to.equal('"≻"');
});
});
});