Browse Source

Add Hero specs

Jeremy Thomas 3 years ago
parent
commit
e093e7b45d
2 changed files with 85 additions and 1 deletions
  1. 11 0
      docs/cyp/layout/hero.html
  2. 74 1
      docs/cypress/integration/layout/hero.spec.js

+ 11 - 0
docs/cyp/layout/hero.html

@@ -18,6 +18,12 @@ title: Layout/Hero
   {{ content }}
 </section>
 
+{% for color in site.data.colors.justColors %}
+  <section id="hero-{{ color }}" class="hero is-{{ color }}">
+    {{ content }}
+  </section>
+{% endfor %}
+
 <section id="hero-small" class="hero is-small">
   {{ content }}
 </section>
@@ -43,3 +49,8 @@ title: Layout/Hero
     {{ content }}
   </div>
 </section>
+
+<div id="hero-buttons" class="hero-buttons"></div>
+<div id="hero-head" class="hero-head"></div>
+<div id="hero-foot" class="hero-foot"></div>
+<div id="hero-body" class="hero-body"></div>

+ 74 - 1
docs/cypress/integration/layout/hero.spec.js

@@ -1,4 +1,4 @@
-import { setDesktop } from "../utils";
+import { setMobile, setDesktop } from "../utils";
 
 describe("Layout/Hero", () => {
   beforeEach(() => {
@@ -20,6 +20,22 @@ describe("Layout/Hero", () => {
     });
   });
 
+  it("has a correct Hero colors", () => {
+    for (let i = 0; i < Cypress.env("color-names").length; i++) {
+      const name = Cypress.env("color-names")[i];
+      const baseColor = Cypress.env(name);
+      const invertColor = Cypress.env(`${name}-invert`);
+      const lightColor = Cypress.env(`${name}-light`);
+      const darkColor = Cypress.env(`${name}-dark`);
+
+      cy.get(`#hero-${name}`).then(($) => {
+        const cs = window.getComputedStyle($[0]);
+        expect(cs.backgroundColor).to.equal(baseColor);
+        expect(cs.color).to.equal(invertColor);
+      });
+    }
+  });
+
   it("has a correct small Hero", () => {
     cy.get("#hero-small .hero-body").then(($) => {
       const cs = window.getComputedStyle($[0]);
@@ -74,4 +90,61 @@ describe("Layout/Hero", () => {
       expect(cs.flexShrink).to.equal("1");
     });
   });
+
+  it("has a Hero Buttons", () => {
+    cy.get(".hero-buttons").should("exist");
+  });
+
+  it("has a correct Hero Buttons", () => {
+    cy.get("#hero-buttons").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.display).to.equal("flex");
+      expect(cs.justifyContent).to.equal("center");
+      expect(cs.marginTop).to.equal("24px");
+    });
+  });
+
+  it("has a Hero Head", () => {
+    cy.get(".hero-head").should("exist");
+  });
+
+  it("has a correct Hero Head", () => {
+    cy.get("#hero-head").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.flexGrow).to.equal("0");
+      expect(cs.flexShrink).to.equal("0");
+    });
+  });
+
+  it("has a Hero Foot", () => {
+    cy.get(".hero-foot").should("exist");
+  });
+
+  it("has a correct Hero Foot", () => {
+    cy.get("#hero-foot").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.flexGrow).to.equal("0");
+      expect(cs.flexShrink).to.equal("0");
+    });
+  });
+
+  it("has a Hero Body", () => {
+    cy.get(".hero-body").should("exist");
+  });
+
+  it("has a correct Hero Body", () => {
+    cy.get("#hero-body").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.flexGrow).to.equal("1");
+      expect(cs.flexShrink).to.equal("0");
+      expect(cs.padding).to.equal("48px");
+    });
+
+    setMobile();
+
+    cy.get("#hero-body").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.padding).to.equal("48px 24px");
+    });
+  });
 });