hero.spec.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { setMobile, setDesktop } from "../utils";
  2. describe("Layout/Hero", () => {
  3. beforeEach(() => {
  4. cy.visit("http://127.0.0.1:4000/cyp/layout/hero/");
  5. setDesktop();
  6. });
  7. it("has a Hero", () => {
  8. cy.get(".hero").should("exist");
  9. });
  10. it("has a correct Hero", () => {
  11. cy.get("#hero").then(($) => {
  12. const cs = window.getComputedStyle($[0]);
  13. expect(cs.alignItems).to.equal("stretch");
  14. expect(cs.display).to.equal("flex");
  15. expect(cs.flexDirection).to.equal("column");
  16. expect(cs.justifyContent).to.equal("space-between");
  17. });
  18. });
  19. it("has a correct Hero colors", () => {
  20. for (let i = 0; i < Cypress.env("color-names").length; i++) {
  21. const name = Cypress.env("color-names")[i];
  22. const baseColor = Cypress.env(name);
  23. const invertColor = Cypress.env(`${name}-invert`);
  24. const lightColor = Cypress.env(`${name}-light`);
  25. const darkColor = Cypress.env(`${name}-dark`);
  26. cy.get(`#hero-${name}`).then(($) => {
  27. const cs = window.getComputedStyle($[0]);
  28. expect(cs.backgroundColor).to.equal(baseColor);
  29. expect(cs.color).to.equal(invertColor);
  30. });
  31. }
  32. });
  33. it("has a correct small Hero", () => {
  34. cy.get("#hero-small .hero-body").then(($) => {
  35. const cs = window.getComputedStyle($[0]);
  36. expect(cs.padding).to.equal("24px");
  37. });
  38. });
  39. it("has a correct medium Hero", () => {
  40. cy.get("#hero-medium .hero-body").then(($) => {
  41. const cs = window.getComputedStyle($[0]);
  42. expect(cs.padding).to.equal("144px 72px");
  43. });
  44. });
  45. it("has a correct large Hero", () => {
  46. cy.get("#hero-large .hero-body").then(($) => {
  47. const cs = window.getComputedStyle($[0]);
  48. expect(cs.padding).to.equal("288px 96px");
  49. });
  50. });
  51. it("has a correct halfheight Hero", () => {
  52. cy.get("#hero-halfheight").then(($) => {
  53. const cs = window.getComputedStyle($[0]);
  54. expect(cs.minHeight).to.equal(`${Cypress.env("viewports").desktop[1] / 2}px`);
  55. });
  56. cy.get("#hero-halfheight .hero-body").then(($) => {
  57. const cs = window.getComputedStyle($[0]);
  58. expect(cs.alignItems).to.equal("center");
  59. expect(cs.display).to.equal("flex");
  60. });
  61. });
  62. it("has a correct fullheight Hero", () => {
  63. cy.get("#hero-fullheight").then(($) => {
  64. const cs = window.getComputedStyle($[0]);
  65. expect(cs.minHeight).to.equal(`${Cypress.env("viewports").desktop[1]}px`);
  66. });
  67. cy.get("#hero-fullheight .hero-body").then(($) => {
  68. const cs = window.getComputedStyle($[0]);
  69. expect(cs.alignItems).to.equal("center");
  70. expect(cs.display).to.equal("flex");
  71. });
  72. });
  73. it("has a correct Hero with container", () => {
  74. cy.get("#hero-with-container > .container").then(($) => {
  75. const cs = window.getComputedStyle($[0]);
  76. expect(cs.flexGrow).to.equal("1");
  77. expect(cs.flexShrink).to.equal("1");
  78. });
  79. });
  80. it("has a Hero Buttons", () => {
  81. cy.get(".hero-buttons").should("exist");
  82. });
  83. it("has a correct Hero Buttons", () => {
  84. cy.get("#hero-buttons").then(($) => {
  85. const cs = window.getComputedStyle($[0]);
  86. expect(cs.display).to.equal("flex");
  87. expect(cs.justifyContent).to.equal("center");
  88. expect(cs.marginTop).to.equal("24px");
  89. });
  90. });
  91. it("has a Hero Head", () => {
  92. cy.get(".hero-head").should("exist");
  93. });
  94. it("has a correct Hero Head", () => {
  95. cy.get("#hero-head").then(($) => {
  96. const cs = window.getComputedStyle($[0]);
  97. expect(cs.flexGrow).to.equal("0");
  98. expect(cs.flexShrink).to.equal("0");
  99. });
  100. });
  101. it("has a Hero Foot", () => {
  102. cy.get(".hero-foot").should("exist");
  103. });
  104. it("has a correct Hero Foot", () => {
  105. cy.get("#hero-foot").then(($) => {
  106. const cs = window.getComputedStyle($[0]);
  107. expect(cs.flexGrow).to.equal("0");
  108. expect(cs.flexShrink).to.equal("0");
  109. });
  110. });
  111. it("has a Hero Body", () => {
  112. cy.get(".hero-body").should("exist");
  113. });
  114. it("has a correct Hero Body", () => {
  115. cy.get("#hero-body").then(($) => {
  116. const cs = window.getComputedStyle($[0]);
  117. expect(cs.flexGrow).to.equal("1");
  118. expect(cs.flexShrink).to.equal("0");
  119. expect(cs.padding).to.equal("48px");
  120. });
  121. setMobile();
  122. cy.get("#hero-body").then(($) => {
  123. const cs = window.getComputedStyle($[0]);
  124. expect(cs.padding).to.equal("48px 24px");
  125. });
  126. });
  127. });