Преглед на файлове

Add tabs specs, Add form checkbox radio specs

Jeremy Thomas преди 3 години
родител
ревизия
41e28cff8a

+ 190 - 0
docs/cyp/components/tabs.html

@@ -0,0 +1,190 @@
+---
+layout: cypress
+title: Components/Tabs
+---
+
+{% capture content_text %}
+  <ul>
+    <li class="is-active"><a>Pictures</a></li>
+    <li><a>Music</a></li>
+    <li><a>Videos</a></li>
+    <li><a>Documents</a></li>
+  </ul>
+{% endcapture %}
+
+{% capture content_icons %}
+  <ul>
+    <li class="is-active">
+      <a>
+        <span class="icon is-small"><i class="fas fa-image" aria-hidden="true"></i></span>
+        <span>Pictures</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="fas fa-music" aria-hidden="true"></i></span>
+        <span>Music</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="fas fa-film" aria-hidden="true"></i></span>
+        <span>Videos</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="far fa-file-alt" aria-hidden="true"></i></span>
+        <span>Documents</span>
+      </a>
+    </li>
+  </ul>
+{% endcapture %}
+
+<div id="tabs-lists" class="tabs">
+  <ul class="is-left">
+    <li class="is-active"><a>Pictures</a></li>
+    <li><a>Music</a></li>
+    <li><a>Videos</a></li>
+    <li><a>Documents</a></li>
+  </ul>
+
+  <ul class="is-center">
+    <li class="is-active"><a>Pictures</a></li>
+    <li><a>Music</a></li>
+    <li><a>Videos</a></li>
+    <li><a>Documents</a></li>
+  </ul>
+
+  <ul class="is-right">
+    <li class="is-active"><a>Pictures</a></li>
+    <li><a>Music</a></li>
+    <li><a>Videos</a></li>
+    <li><a>Documents</a></li>
+  </ul>
+</div>
+
+<div id="tabs" class="tabs">
+  {{ content_text }}
+</div>
+
+<div id="tabs-centered" class="tabs is-centered">
+  {{ content_text }}
+</div>
+
+<div id="tabs-right" class="tabs is-right">
+  {{ content_text }}
+</div>
+
+<div id="tabs-small" class="tabs is-small">
+  {{ content_text }}
+</div>
+
+<div id="tabs-medium" class="tabs is-medium">
+  {{ content_text }}
+</div>
+
+<div id="tabs-large" class="tabs is-large">
+  {{ content_text }}
+</div>
+
+<div id="tabs-boxed" class="tabs is-boxed">
+  {{ content_icons }}
+</div>
+
+<div id="tabs-toggle" class="tabs is-toggle">
+  {{ content_icons }}
+</div>
+
+<div id="tabs-toggle-rounded" class="tabs is-toggle is-toggle-rounded">
+  <ul>
+    <li class="is-active">
+      <a>
+        <span class="icon is-small"><i class="fas fa-image"></i></span>
+        <span>Pictures</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="fas fa-music"></i></span>
+        <span>Music</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="fas fa-film"></i></span>
+        <span>Videos</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon is-small"><i class="fas fa-file-alt"></i></span>
+        <span>Documents</span>
+      </a>
+    </li>
+  </ul>
+</div>
+
+<div id="tabs-fullwidth" class="tabs is-fullwidth">
+  <ul>
+    <li>
+      <a>
+        <span class="icon"><i class="fas fa-angle-left" aria-hidden="true"></i></span>
+        <span>Left</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon"><i class="fas fa-angle-up" aria-hidden="true"></i></span>
+        <span>Up</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span>Right</span>
+        <span class="icon"><i class="fas fa-angle-right" aria-hidden="true"></i></span>
+      </a>
+    </li>
+  </ul>
+</div>
+
+<div id="tabs-centered-boxed" class="tabs is-centered is-boxed">
+  {{ content_icons }}
+</div>
+
+<div id="tabs-toggle-fullwidth" class="tabs is-toggle is-fullwidth">
+  {{ content_icons }}
+</div>
+
+<div id="tabs-centered-boxed-medium" class="tabs is-centered is-boxed is-medium">
+  {{ content_icons }}
+</div>
+
+<div id="tabs-toggle-fullwidth-large" class="tabs is-toggle is-fullwidth is-large">
+  <ul>
+    <li class="is-active">
+      <a>
+        <span class="icon"><i class="fas fa-image" aria-hidden="true"></i></span>
+        <span>Pictures</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon"><i class="fas fa-music" aria-hidden="true"></i></span>
+        <span>Music</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon"><i class="fas fa-film" aria-hidden="true"></i></span>
+        <span>Videos</span>
+      </a>
+    </li>
+    <li>
+      <a>
+        <span class="icon"><i class="far fa-file-alt" aria-hidden="true"></i></span>
+        <span>Documents</span>
+      </a>
+    </li>
+  </ul>
+</div>

+ 29 - 0
docs/cyp/form/checkbox-radio.html

@@ -0,0 +1,29 @@
+---
+layout: cypress
+title: Form/Checkbox Radio
+---
+
+<label id="checkbox" class="checkbox">
+  <input type="checkbox">
+  I agree to the <a href="#">terms and conditions</a>
+</label>
+
+<label id="checkbox-disabled" class="checkbox" disabled>
+  <input type="checkbox" disabled>
+  Save my preferences
+</label>
+
+<div id="radio" class="control">
+  <label class="radio">
+    <input type="radio" name="rsvp">
+    Going
+  </label>
+  <label class="radio">
+    <input type="radio" name="rsvp">
+    Not going
+  </label>
+  <label class="radio" disabled>
+    <input type="radio" name="rsvp" disabled>
+    Maybe
+  </label>
+</div>

+ 103 - 0
docs/cypress/integration/components/tabs.spec.js

@@ -0,0 +1,103 @@
+describe("Components/Tabs", () => {
+  beforeEach(() => {
+    cy.visit("http://127.0.0.1:4000/cyp/components/tabs/");
+  });
+
+  it("has a Tabs", () => {
+    cy.get(".tabs").should("exist");
+  });
+
+  it("has a correct Tabs", () => {
+    cy.get("#tabs").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.alignItems).to.equal("stretch");
+      expect(cs.display).to.equal("flex");
+      expect(cs.fontSize).to.equal("16px");
+      expect(cs.justifyContent).to.equal("space-between");
+      expect(cs.whiteSpace).to.equal("nowrap");
+    });
+
+    cy.get("#tabs li:not(.is-active) a").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.alignItems).to.equal("center");
+      expect(cs.borderBottomColor).to.equal(Cypress.env("border"));
+      expect(cs.borderBottomStyle).to.equal("solid");
+      expect(cs.borderBottomWidth).to.equal("1px");
+      expect(cs.color).to.equal(Cypress.env("text"));
+      expect(cs.display).to.equal("flex");
+      expect(cs.justifyContent).to.equal("center");
+      expect(cs.marginBottom).to.equal("-1px");
+      expect(cs.padding).to.equal("8px 16px");
+      expect(cs.verticalAlign).to.equal("top");
+    });
+
+    cy.get("#tabs li.is-active a").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.borderBottomColor).to.equal(Cypress.env("link"));
+      expect(cs.color).to.equal(Cypress.env("link"));
+    });
+
+    cy.get("#tabs ul").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.alignItems).to.equal("center");
+      expect(cs.borderBottomColor).to.equal(Cypress.env("border"));
+      expect(cs.borderBottomStyle).to.equal("solid");
+      expect(cs.borderBottomWidth).to.equal("1px");
+      expect(cs.display).to.equal("flex");
+      expect(cs.flexGrow).to.equal("1");
+      expect(cs.flexShrink).to.equal("0");
+      expect(cs.justifyContent).to.equal("flex-start");
+    });
+  });
+
+  it("has a correct Tabs alignments", () => {
+    cy.get("#tabs-centered ul").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.justifyContent).to.equal("center");
+    });
+
+    cy.get("#tabs-right ul").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.justifyContent).to.equal("flex-end");
+    });
+  });
+
+  it("has a correct Tabs lists alignments", () => {
+    cy.get("#tabs-lists ul.is-left").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.paddingRight).to.equal("12px");
+    });
+
+    cy.get("#tabs-lists ul.is-center").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.flex).to.equal("0 0 auto");
+      expect(cs.justifyContent).to.equal("center");
+      expect(cs.paddingLeft).to.equal("12px");
+      expect(cs.paddingRight).to.equal("12px");
+    });
+
+    cy.get("#tabs-lists ul.is-right").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.justifyContent).to.equal("flex-end");
+      expect(cs.paddingLeft).to.equal("12px");
+    });
+  });
+
+  it("has a correct boxed Tabs", () => {
+    cy.get("#tabs-boxed li:not(.is-active) a").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.borderColor).to.equal(Cypress.env("transparent"));
+      expect(cs.borderRadius).to.equal("4px 4px 0px 0px");
+    });
+
+    cy.get("#tabs-boxed li.is-active a").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.backgroundColor).to.equal(Cypress.env("scheme-main"));
+      expect(cs.borderColor).to.equal(
+        `${Cypress.env("border")} ${Cypress.env("border")} ${Cypress.env(
+          "transparent"
+        )}`
+      );
+    });
+  });
+});

+ 77 - 0
docs/cypress/integration/form/checkbox-radio.spec.js

@@ -0,0 +1,77 @@
+describe("Form/Checkbox", () => {
+  beforeEach(() => {
+    cy.visit("http://127.0.0.1:4000/cyp/form/checkbox-radio/");
+  });
+
+  it("has a Checkbox", () => {
+    cy.get(".checkbox").should("exist");
+  });
+
+  it("has a correct Checkbox", () => {
+    cy.get("#checkbox").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.cursor).to.equal("pointer");
+      expect(cs.display).to.equal("inline-block");
+      expect(cs.lineHeight).to.equal("20px");
+      expect(cs.position).to.equal("relative");
+    });
+
+    cy.get("#checkbox input").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.cursor).to.equal("pointer");
+    });
+  });
+
+  it("has a correct disabled Checkbox", () => {
+    cy.get("#checkbox-disabled").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.color).to.equal(Cypress.env("text-light"));
+      expect(cs.cursor).to.equal("not-allowed");
+    });
+
+    cy.get("#checkbox-disabled input").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.cursor).to.equal("not-allowed");
+    });
+  });
+});
+
+describe("Form/Radio", () => {
+  beforeEach(() => {
+    cy.visit("http://127.0.0.1:4000/cyp/form/checkbox-radio/");
+  });
+
+  it("has a Radio", () => {
+    cy.get(".radio").should("exist");
+  });
+
+  it("has a correct Radio", () => {
+    cy.get("#radio .radio").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.cursor).to.equal("pointer");
+      expect(cs.display).to.equal("inline-block");
+      expect(cs.lineHeight).to.equal("20px");
+      expect(cs.position).to.equal("relative");
+    });
+
+    cy.get("#radio input").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.cursor).to.equal("pointer");
+    });
+  });
+
+  it("has a correct disabled Radio", () => {
+    cy.get("#radio .radio[disabled]").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.color).to.equal(Cypress.env("text-light"));
+      expect(cs.cursor).to.equal("not-allowed");
+    });
+  });
+
+  it("has correct Radio spacing", () => {
+    cy.get("#radio .radio + .radio").then(($) => {
+      const cs = window.getComputedStyle($[0]);
+      expect(cs.marginLeft).to.equal("8px");
+    });
+  });
+});