removeProp.test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. require("./chai.helper");
  2. var domHelper = require("./dom.helper");
  3. describe("removeProp", function () {
  4. beforeEach(function () {
  5. domHelper(
  6. "<div id=\"no1\"></div>" +
  7. "<div id=\"no2\"></div>" +
  8. "<div id=\"no3\"></div>"
  9. );
  10. $("div").prop("data-jig", "fancy");
  11. $("div").prop("data-prance", "hurray");
  12. // check props are set
  13. var count = 0;
  14. $("div").each(function (index, item) {
  15. count += 1;
  16. $(item).prop("data-jig").should.equal("fancy");
  17. $(item).prop("data-prance").should.equal("hurray");
  18. });
  19. count.should.equal(3);
  20. });
  21. it("should remove a property from elements", function () {
  22. var count = 0;
  23. // check one prop is removed
  24. $("div").removeProp("data-jig");
  25. $("div").each(function (index, item) {
  26. count += 1;
  27. ($(item).prop("data-jig") === undefined).should.be.true;
  28. $(item).prop("data-prance").should.equal("hurray");
  29. });
  30. count.should.equal(3);
  31. });
  32. it("should remove multiple properties on elements when passed an object", function () {
  33. var count = 0;
  34. // check all props are removed
  35. $("div").removeProp("data-jig data-prance");
  36. $("div").each(function (index, item) {
  37. count += 1;
  38. ($(item).prop("data-jig") === undefined).should.be.true;
  39. ($(item).prop("data-prance") === undefined).should.be.true;
  40. });
  41. count.should.equal(3);
  42. });
  43. });