css.test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. require("./chai.helper");
  2. var domHelper = require("./dom.helper");
  3. describe("css", function () {
  4. beforeEach(function () {
  5. domHelper(
  6. "<div id=\"no1\"></div>"
  7. );
  8. });
  9. it("should read a CSS property from an element", function () {
  10. var expected = "green";
  11. document.getElementById("no1").style["background-color"] = expected;
  12. var actual = $("#no1").css("background-color");
  13. actual.should.equal(expected);
  14. });
  15. it("should set a CSS property on an element", function () {
  16. var expected = "green";
  17. $("#no1").css("background-color", expected);
  18. var actual = document.getElementById("no1").style["background-color"];
  19. actual.should.equal(expected);
  20. });
  21. it("should write multiple CSS properties to an element", function () {
  22. $("#no1").css({
  23. "height": "100px",
  24. "background-color": "#CCC"
  25. });
  26. var elt = document.getElementById("no1");
  27. elt.style["height"].should.equal("100px");
  28. elt.style["background-color"].should.equal("#CCC");
  29. });
  30. });