shim.test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. describe("shimTest", function () {
  2. beforeEach(function () {
  3. $(document.body).append("<div id=\"moo\"></div>");
  4. });
  5. it("should $.query find the dom node", function () {
  6. var el=document.getElementById("moo");
  7. $("#moo").length.should.eql(1);
  8. });
  9. it("should fail on the $.query selector",function(){
  10. var foo=$.query("@#$<ASDFASDF>!#");
  11. foo.length.should.eql(0);
  12. })
  13. it("should $.create create dom nodes",function(){
  14. var tmp=$.create("div",{html:"foobar"});
  15. tmp.get(0).nodeName.toLowerCase().should.eql("div");
  16. tmp.get(0).innerHTML.should.eql("foobar");
  17. var tmp=$.create("<div>foobar</div>");
  18. tmp.get(0).nodeName.toLowerCase().should.eql("div");
  19. tmp.get(0).innerHTML.should.eql("foobar");
  20. });
  21. it("should be an object", function(){
  22. var obj={};
  23. expect($.isObject(obj)).to.be.true;
  24. });
  25. it("should be a jQuery Object", function(){
  26. var obj=$();
  27. expect($.is$(obj)).to.be.true;
  28. });
  29. it("should create a touchlist",function(){
  30. var tl=new $.feat.TouchList();
  31. tl.length.should.eql(0);
  32. });
  33. it("should create a touch item",function(){
  34. var touch=new $.feat.Touch();
  35. expect(touch.identifier>=1000).to.be.true;
  36. });
  37. it("should have a touch list with one item",function(){
  38. var tl=new $.feat.TouchList();
  39. var touch=new $.feat.Touch();
  40. tl._add(touch);
  41. tl.length.should.eql(1);
  42. touch.should.eql(tl.item(0));
  43. });
  44. it("should get the computed style",function(){
  45. var ele=document.getElementById("moo");
  46. moo.style.width="30px";
  47. $("#moo").computedStyle("width").should.eql("30px");
  48. })
  49. it("should return the object if nothing is passed to computed style",function(){
  50. var ele=document.getElementById("moo");
  51. moo.style.width="30px";
  52. expect($("#moo3").computedStyle()===undefined).to.be.true;
  53. });
  54. it("should have a length of 36 for $.uuid",function(){
  55. $.uuid().length.should.eql(36);
  56. })
  57. });