Advertisement
Guest User

Untitled

a guest
Jun 10th, 2011
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1.  
  2. SCRIPT445: Object doesn't support this action
  3. jQuery-plugin-scaffold.js, line 140 character 9
  4. Test Testing Identity died, exception and test follows
  5. TypeError: Object doesn't support property or method 'Identity'
  6. function _Identity() {
  7. var one = $("#one");
  8. var div = $("div");
  9.  
  10. stop();
  11. var go = after(7, function() {
  12. I._create(document.body).destroy();
  13. start();
  14. });
  15. start();
  16.  
  17. var testThen = function _testThen(ret) {
  18. ok(testReturnValue(ret, one[0]), "return value is wrong")
  19. go();
  20. }
  21.  
  22. var testThenObj = function _testThenObj(ret) {
  23. ok(testReturnValue(ret, one[0]), "return value is wrong");
  24. ok(ret[0].options.foo === "bar",
  25. "options are not stored properly on the Wrap");
  26. go();
  27. }
  28.  
  29. var identity = one.Identity();
  30. ok(identity.isRejected && identity.isResolved,
  31. "Identity does not return deferred");
  32.  
  33. one.Identity().then(testThen);
  34.  
  35. one.Identity({"foo": "bar"}).then(testThenObj);
  36.  
  37. one.Identity({
  38. "cb": testThen
  39. });
  40.  
  41. one.Identity("Identity").then(testThen);
  42.  
  43. one.Identity("Identity", {"foo": "bar"}).then(testThenObj);
  44.  
  45. one.Identity("Identity", {
  46. "cb": function _cb(ret) {
  47. ok(testReturnValue(ret, one[0]), "return value is wrong");
  48. strictEqual(ret[0].options.cb, _cb,
  49. "callback not stored on options");
  50. go();
  51. }
  52. });
  53.  
  54. div.Identity().then(function _multipleReturns(ret) {
  55. strictEqual(4, arguments.length,
  56. "The deferred array passed back is missing elements");
  57. Array.prototype.forEach.call(arguments, function(ret, k) {
  58. ok(testReturnValue(ret, ret[1]), "return value is wrong");
  59. ok(div.toArray().some(
  60. function _divContainsRet(elem) {
  61. return elem === ret[1];
  62. }),
  63. "returned identities do not contain the right divs"
  64. );
  65. });
  66. go();
  67. });
  68.  
  69.  
  70. }
  71. Test Testing jQuery.Identity died, exception and test follows
  72. TypeError: typeof prototype[undefined] != 'object'
  73. function _jQueryIdentity() {
  74. var one = $("#one");
  75. var div = $("div");
  76.  
  77. stop();
  78. var go = after(17, function() {
  79. I._create(document.body).destroy();
  80. start();
  81. });
  82. start();
  83.  
  84. var testThen = function _testThen($elem, ret) {
  85. //console.log($elem, ret);
  86. ok(testReturnValue(ret, $elem[0]), "return value is wrong")
  87. go();
  88. }
  89.  
  90. var testThenObj = function _testThenObj($elem, ret) {
  91. ok(testReturnValue(ret, $elem[0]), "return value is wrong");
  92. ok(ret[0].options.foo === "bar",
  93. "options are not stored properly on the Wrap");
  94. go();
  95. }
  96.  
  97. var testThenBody = testThen.bind(null, $(document.body));
  98. var testThenObjBody = testThenObj.bind(null, $(document.body));
  99.  
  100. var testThenOne = testThen.bind(null, one);
  101. var testThenObjOne = testThenObj.bind(null, one);
  102.  
  103. var testThenDiv = testThen.bind(null, div);
  104. var testThenObjDiv = testThenObj.bind(null, div);
  105.  
  106. var identity = I();
  107. ok(identity.isRejected && identity.isResolved,
  108. "Identity does not return deferred");
  109.  
  110. I().then(testThenBody);
  111. I({"foo":"bar"}).then(testThenObjBody);
  112. I({
  113. "foo":"bar",
  114. "cb": testThenObjBody
  115. });
  116. I({
  117. "foo": "bar",
  118. "elem": one[0]
  119. }).then(testThenObjOne);
  120. I({
  121. "foo":"bar",
  122. "elem": $.makeArray(div)
  123. }).then(testThenObjDiv);
  124. I("Identity").then(testThenBody)
  125. I("Identity", {"foo": "bar"}).then(testThenObjBody);
  126. I("Identity", {
  127. "foo": "bar",
  128. "elem": one[0]
  129. }).then(testThenObjOne);
  130. I("Identity", {
  131. "foo":"bar",
  132. "elem": $.makeArray(div)
  133. }).then(testThenObjDiv);
  134. I(one[0]).then(testThenOne);
  135. I($.makeArray(div)).then(testThenDiv);
  136. I(one[0], {
  137. "foo": "bar"
  138. }).then(testThenObjOne);
  139. I($.makeArray(div), {
  140. "foo": "bar"
  141. }).then(testThenObjDiv);
  142. I(one[0], "Identity").then(testThenOne);
  143. I($.makeArray(div), "Identity").then(testThenDiv);
  144. I(one[0], {
  145. "foo": "bar"
  146. }, "Identity").then(testThenObjOne);
  147. I($.makeArray(div), {
  148. "foo": "bar"
  149. }, "Identity").then(testThenObjDiv);
  150. I._create(document.body).destroy();
  151.  
  152. }
  153. Test Create died, exception and test follows
  154. TypeError: Function expected
  155. function _Create() {
  156. var c = I._create;
  157.  
  158. var o = c(document.body);
  159. var p = c(document.body);
  160. var q = c($("div")[0]);
  161. strictEqual(o, p, "create does not cache");
  162. ok(I._Wrap.isPrototypeOf(o), "o is not instance of Wrap");
  163. ok(o.elem, "Wrap does not have an element");
  164. ok(o.$elem, "Wrap does not have a $element");
  165. ok(o.uid, "Wrap does not have a uid");
  166. ok(o._ns, "Wrap does not have a event namespace");
  167. ok(o.data, "Wrap does not have a data method");
  168. ok(o._init, "Wrap does not have an init method");
  169. ok(o.destroy, "Wrap does not have a destroy method");
  170. ok(o.Identity, "Wrap does not have an Identity method");
  171. notEqual(o.uid, q.uid, "uid is not unique");
  172. notEqual(o._ns, q._ns, "ns is not unique");
  173. strictEqual(o._ns, o.data("_ns"),
  174. "the event namespace is not stored in data properely")
  175.  
  176. o.Identity();
  177. ok(o.options, "options does not exist on Wrapped object");
  178. o.destroy();
  179. }
  180. Test Data died, exception and test follows
  181. TypeError: Function expected
  182. function _Data() {
  183. var c = I._create;
  184.  
  185. var o = c(document.body);
  186. o.data("foo", "bar");
  187. strictEqual(o.data("foo"), "bar",
  188. "data is not stored properly in data");
  189. o.data({"foo2": "bar2"});
  190. strictEqual(o.data("foo2"), "bar2",
  191. "data is not stored properly for objects");
  192. var p = o.data();
  193. deepEqual(p, {
  194. "_ns": o._ns,
  195. "foo": "bar",
  196. "foo2": "bar2"
  197. }, "stored data is not as expected");
  198.  
  199. [1, true, {"foo": "bar"}, [1,2,3], "foz", undefined, null]
  200. .forEach(function _each(v) {
  201. o.data("foo", v);
  202. deepEqual(v, o.data("foo"), "Could not set " + v + "on data");
  203. })
  204. o.destroy();
  205. }
  206. Test Destroy died, exception and test follows
  207. TypeError: Function expected
  208. function _Destroy() {
  209. var c = I._create;
  210.  
  211. var o = c(document.body);
  212. o.destroy();
  213. o._init();
  214. var foo = 42;
  215. o.$elem.bind("click", function _click() {
  216. foo = null;
  217. })
  218. $(o.elem).one("click", function _continue() {
  219. equal(foo, 42, "click event was not unbound");
  220. equal(o.data("foo"), undefined, "data was not removed");
  221. strictEqual(o.options, undefined);
  222. start();
  223. })
  224. o.data("foo", "bar");
  225. o.destroy();
  226. o.$elem.click();
  227. }
  228. Test Bind died, exception and test follows
  229. TypeError: Function expected
  230. function _Bind() {
  231. var c = I._create;
  232.  
  233. var o = c(document.body);
  234. var foo = 42;
  235. o.$elem.bind("click", function _click() {
  236. foo = null;
  237. })
  238. $(o.elem).one("click", function _continue() {
  239. equal(foo, 42, "click event was not bound properly");
  240. o.destroy();
  241. start();
  242. });
  243. $(o.elem).unbind("click" + o._ns);
  244. o.$elem.click();
  245. }
  246. Test UnBind died, exception and test follows
  247. TypeError: Function expected
  248. function _Bind() {
  249. var c = I._create;
  250.  
  251. var o = c(document.body);
  252. var foo = 42;
  253. $(o.elem).bind("click" + o._ns, function _click() {
  254. foo = null;
  255. })
  256. $(o.elem).one("click", function _continue() {
  257. equal(foo, 42, "click event was not unbound properly");
  258. o.destroy();
  259. o._init();
  260. $(o.elem).bind("click" + o._ns, function _click2() {
  261. foo = null;
  262. })
  263. $(o.elem).one("click", function _continue2() {
  264. equal(foo, 42, "namespace was not unbound properly");
  265. o.destroy();
  266. start();
  267. });
  268. o.$elem.unbind();
  269. o.$elem.click();
  270. })
  271. o.$elem.unbind("click");
  272. o.$elem.click();
  273.  
  274. }
  275. Test Global died, exception and test follows
  276. TypeError: Function expected
  277. function _Global() {
  278. var c = I._create;
  279. $.Identity.global = { "baz": "bar" };
  280.  
  281. var o = c(document.body);
  282. o.Identity();
  283. strictEqual(o.options.baz, "bar",
  284. "globals were not changed");
  285. o.Identity({ "baz": "foo"});
  286. strictEqual(o.options.baz, "foo",
  287. "globals cannot be overwritten");
  288. o.Identity({ "bar": "boz"});
  289. strictEqual(o.options.bar, "boz",
  290. "cannot set other properties on options");
  291.  
  292. $.Identity.global.baz = "foo";
  293. o.Identity();
  294. strictEqual(o.options.baz, "foo",
  295. "Cannot change globals through assignment");
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement