checkbox-radio.spec.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. describe("Form/Checkbox", () => {
  2. beforeEach(() => {
  3. cy.visit("http://127.0.0.1:4000/cyp/form/checkbox-radio/");
  4. });
  5. it("has a Checkbox", () => {
  6. cy.get(".checkbox").should("exist");
  7. });
  8. it("has a correct Checkbox", () => {
  9. cy.get("#checkbox").then(($) => {
  10. const cs = window.getComputedStyle($[0]);
  11. expect(cs.cursor).to.equal("pointer");
  12. expect(cs.display).to.equal("inline-block");
  13. expect(cs.lineHeight).to.equal("20px");
  14. expect(cs.position).to.equal("relative");
  15. });
  16. cy.get("#checkbox input").then(($) => {
  17. const cs = window.getComputedStyle($[0]);
  18. expect(cs.cursor).to.equal("pointer");
  19. });
  20. });
  21. it("has a correct disabled Checkbox", () => {
  22. cy.get("#checkbox-disabled").then(($) => {
  23. const cs = window.getComputedStyle($[0]);
  24. expect(cs.color).to.equal(Cypress.env("text-light"));
  25. expect(cs.cursor).to.equal("not-allowed");
  26. });
  27. cy.get("#checkbox-disabled input").then(($) => {
  28. const cs = window.getComputedStyle($[0]);
  29. expect(cs.cursor).to.equal("not-allowed");
  30. });
  31. });
  32. });
  33. describe("Form/Radio", () => {
  34. beforeEach(() => {
  35. cy.visit("http://127.0.0.1:4000/cyp/form/checkbox-radio/");
  36. });
  37. it("has a Radio", () => {
  38. cy.get(".radio").should("exist");
  39. });
  40. it("has a correct Radio", () => {
  41. cy.get("#radio .radio").then(($) => {
  42. const cs = window.getComputedStyle($[0]);
  43. expect(cs.cursor).to.equal("pointer");
  44. expect(cs.display).to.equal("inline-block");
  45. expect(cs.lineHeight).to.equal("20px");
  46. expect(cs.position).to.equal("relative");
  47. });
  48. cy.get("#radio input").then(($) => {
  49. const cs = window.getComputedStyle($[0]);
  50. expect(cs.cursor).to.equal("pointer");
  51. });
  52. });
  53. it("has a correct disabled Radio", () => {
  54. cy.get("#radio .radio[disabled]").then(($) => {
  55. const cs = window.getComputedStyle($[0]);
  56. expect(cs.color).to.equal(Cypress.env("text-light"));
  57. expect(cs.cursor).to.equal("not-allowed");
  58. });
  59. });
  60. it("has correct Radio spacing", () => {
  61. cy.get("#radio .radio + .radio").then(($) => {
  62. const cs = window.getComputedStyle($[0]);
  63. expect(cs.marginLeft).to.equal("8px");
  64. });
  65. });
  66. });