generic.spec.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { familyPrimary } from "../utils";
  2. describe("Base/Generic", () => {
  3. beforeEach(() => {
  4. cy.visit("http://127.0.0.1:4000/cyp/base/generic/");
  5. });
  6. it("has a correct html", () => {
  7. cy.get("html").then(($) => {
  8. const cs = window.getComputedStyle($[0]);
  9. expect(cs.backgroundColor).to.equal(Cypress.env("scheme-main"));
  10. expect(cs.fontSize).to.equal("16px");
  11. expect(cs.minWidth).to.equal("300px");
  12. expect(cs.overflowX).to.equal("hidden");
  13. expect(cs.overflowY).to.equal("scroll");
  14. expect(cs.textRendering).to.equal("optimizelegibility");
  15. expect(cs.textSizeAdjust).to.equal("100%");
  16. expect(cs.webkitFontSmoothing).to.equal("antialiased");
  17. });
  18. });
  19. it("has correct HTML5 elements", () => {
  20. cy.get("article, aside, figure, footer, header, hgroup, section").then(
  21. ($) => {
  22. const cs = window.getComputedStyle($[0]);
  23. expect(cs.display).to.equal("block");
  24. }
  25. );
  26. });
  27. it("has correct form elements", () => {
  28. cy.get("body, button, input, optgroup, select, textarea").then(($) => {
  29. const cs = window.getComputedStyle($[0]);
  30. expect(cs.fontFamily).to.contains("system-ui");
  31. expect(cs.fontFamily).to.contains("-apple-system");
  32. expect(cs.fontFamily).to.contains("Helvetica");
  33. expect(cs.fontFamily).to.contains("Arial");
  34. expect(cs.fontFamily).to.contains("sans-serif");
  35. });
  36. });
  37. it("has correct monospace elements", () => {
  38. cy.get("pre, code").then(($) => {
  39. const cs = window.getComputedStyle($[0]);
  40. expect(cs.fontFamily).to.equal(Cypress.env("family-code"));
  41. expect(cs.webkitFontSmoothing).to.equal("auto");
  42. });
  43. });
  44. it("has a correct body", () => {
  45. cy.get("body").then(($) => {
  46. const cs = window.getComputedStyle($[0]);
  47. expect(cs.color).to.equal(Cypress.env("text"));
  48. expect(cs.fontFamily).to.contains("system-ui");
  49. expect(cs.fontFamily).to.contains("-apple-system");
  50. expect(cs.fontFamily).to.contains("Helvetica");
  51. expect(cs.fontFamily).to.contains("Arial");
  52. expect(cs.fontFamily).to.contains("sans-serif");
  53. expect(cs.fontSize).to.equal("16px");
  54. expect(cs.fontWeight).to.equal("400");
  55. expect(cs.lineHeight).to.equal("24px");
  56. });
  57. });
  58. it("has a correct a", () => {
  59. cy.get("a").then(($) => {
  60. const cs = window.getComputedStyle($[0]);
  61. expect(cs.color).to.equal(Cypress.env("link"));
  62. expect(cs.cursor).to.equal("pointer");
  63. expect(cs.textDecorationLine).to.equal("none");
  64. });
  65. });
  66. it("has a correct code", () => {
  67. cy.get("code").then(($) => {
  68. const cs = window.getComputedStyle($[0]);
  69. expect(cs.backgroundColor).to.equal(Cypress.env("white-ter"));
  70. expect(cs.color).to.equal(Cypress.env("code"));
  71. });
  72. });
  73. it("has a correct hr", () => {
  74. cy.get("hr").then(($) => {
  75. const cs = window.getComputedStyle($[0]);
  76. expect(cs.backgroundColor).to.equal(Cypress.env("white-ter"));
  77. expect(cs.borderStyle).to.equal("none");
  78. expect(cs.display).to.equal("block");
  79. expect(cs.height).to.equal("2px");
  80. expect(cs.margin).to.equal("24px 0px");
  81. });
  82. });
  83. it("has a correct img", () => {
  84. cy.get("img").then(($) => {
  85. const cs = window.getComputedStyle($[0]);
  86. expect(cs.height).to.equal("28px");
  87. expect(cs.width).to.equal("112px");
  88. });
  89. });
  90. it("has a correct checkbox", () => {
  91. cy.get("input[type='checkbox']").then(($) => {
  92. const cs = window.getComputedStyle($[0]);
  93. expect(cs.verticalAlign).to.equal("baseline");
  94. });
  95. });
  96. it("has a correct radio", () => {
  97. cy.get("input[type='radio']").then(($) => {
  98. const cs = window.getComputedStyle($[0]);
  99. expect(cs.verticalAlign).to.equal("baseline");
  100. });
  101. });
  102. it("has a correct small", () => {
  103. cy.get("small").then(($) => {
  104. const cs = window.getComputedStyle($[0]);
  105. expect(cs.fontSize).to.equal("14px");
  106. });
  107. });
  108. it("has a correct fieldset", () => {
  109. cy.get("fieldset").then(($) => {
  110. const cs = window.getComputedStyle($[0]);
  111. expect(cs.borderStyle).to.equal("none");
  112. });
  113. });
  114. it("has a correct pre", () => {
  115. cy.get("pre").then(($) => {
  116. const cs = window.getComputedStyle($[0]);
  117. expect(cs.backgroundColor).to.equal(Cypress.env("white-ter"));
  118. expect(cs.color).to.equal(Cypress.env("text"));
  119. expect(cs.fontSize).to.equal("14px");
  120. expect(cs.overflowX).to.equal("auto");
  121. expect(cs.padding).to.equal("20px 24px");
  122. expect(cs.whiteSpace).to.equal("pre");
  123. expect(cs.wordWrap).to.equal("normal");
  124. });
  125. cy.get("pre code").then(($) => {
  126. const cs = window.getComputedStyle($[0]);
  127. expect(cs.backgroundColor).to.equal(Cypress.env("transparent"));
  128. expect(cs.color).to.equal(Cypress.env("text"));
  129. expect(cs.fontSize).to.equal("14px");
  130. expect(cs.padding).to.equal("0px");
  131. });
  132. });
  133. });