tiles.spec.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {
  2. setMobile,
  3. setTablet,
  4. setDesktop,
  5. setWidescreen,
  6. setFullHD,
  7. } from "../utils";
  8. describe("Grid/Tiles", () => {
  9. beforeEach(() => {
  10. cy.visit("http://127.0.0.1:4000/cyp/grid/tiles/");
  11. setDesktop();
  12. });
  13. it("has a Tile", () => {
  14. cy.get(".tile").should("exist");
  15. });
  16. it("has a correct Tile", () => {
  17. cy.get("#tile").then(($) => {
  18. const cs = window.getComputedStyle($[0]);
  19. expect(cs.alignItems).to.equal("stretch");
  20. expect(cs.display).to.equal("flex");
  21. expect(cs.flexBasis).to.equal("0px");
  22. expect(cs.flexGrow).to.equal("1");
  23. expect(cs.flexShrink).to.equal("1");
  24. expect(cs.minHeight).to.equal("min-content");
  25. });
  26. });
  27. it("has a correct ancestor Tile", () => {
  28. cy.get("#tile-ancestor").then(($) => {
  29. const cs = window.getComputedStyle($[0]);
  30. expect(cs.marginBottom).to.equal("12px");
  31. expect(cs.marginLeft).to.equal("-12px");
  32. expect(cs.marginRight).to.equal("-12px");
  33. expect(cs.marginTop).to.equal("-12px");
  34. });
  35. });
  36. it("has a correct last ancestor Tile", () => {
  37. cy.get("#tile-ancestor-last").then(($) => {
  38. const cs = window.getComputedStyle($[0]);
  39. expect(cs.marginBottom).to.equal("-12px");
  40. expect(cs.marginLeft).to.equal("-12px");
  41. expect(cs.marginRight).to.equal("-12px");
  42. expect(cs.marginTop).to.equal("-12px");
  43. });
  44. });
  45. it("has a correct parent Tile", () => {
  46. cy.get("#tile-parent").then(($) => {
  47. const cs = window.getComputedStyle($[0]);
  48. expect(cs.padding).to.equal("12px");
  49. });
  50. });
  51. it("has a correct vertical Tile", () => {
  52. cy.get("#tile-vertical").then(($) => {
  53. const cs = window.getComputedStyle($[0]);
  54. expect(cs.flexDirection).to.equal("column");
  55. });
  56. });
  57. it("has a correct child Tile", () => {
  58. cy.get("#tile-child").then(($) => {
  59. const cs = window.getComputedStyle($[0]);
  60. expect(cs.marginBottom).to.equal("0px");
  61. expect(cs.marginLeft).to.equal("0px");
  62. expect(cs.marginRight).to.equal("0px");
  63. expect(cs.marginTop).to.equal("0px");
  64. });
  65. });
  66. it("has a correct vertical child Tile", () => {
  67. cy.get("#tile-vertical-child").then(($) => {
  68. const cs = window.getComputedStyle($[0]);
  69. expect(cs.marginBottom).to.equal("24px");
  70. });
  71. });
  72. it("has a correct Tile sizes", () => {
  73. for (let i = 1; i <= 12; i++) {
  74. cy.get(`#tile-${i}`).then(($) => {
  75. const cs = window.getComputedStyle($[0]);
  76. const actualWidth = cs.width.substring(0, cs.width.length - 2);
  77. expect(cs.flexBasis).to.equal("auto");
  78. expect(cs.flexGrow).to.equal("0");
  79. expect(cs.flexShrink).to.equal("0");
  80. expect(`${Math.round(actualWidth)}px`).to.equal(
  81. `${Math.round((i / 12) * 1000)}px`
  82. );
  83. });
  84. }
  85. });
  86. });