JQuery-Tests.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. smalltalk.addClass('JQueryTest', smalltalk.TestCase, ['document'], 'JQuery-Tests');
  2. smalltalk.addMethod(
  3. '_testFind',
  4. smalltalk.method({
  5. selector: 'testFind',
  6. category: 'tests',
  7. fn: function (){
  8. var self=this;
  9. smalltalk.send(self, "_assert_equals_", ["James", smalltalk.send(smalltalk.send(smalltalk.send(self['@document'], "_asJQuery", []), "_find_", ["li.firstname"]), "_html", [])]);
  10. return self;},
  11. source: unescape('testFind%0A%09self%20%0A%09%09assert%3A%20%27James%27%20%0A%09%09equals%3A%20%28document%20asJQuery%20find%3A%20%27li.firstname%27%29%20html.%20'),
  12. messageSends: ["assert:equals:", "html", "find:", "asJQuery"],
  13. referencedClasses: []
  14. }),
  15. smalltalk.JQueryTest);
  16. smalltalk.addMethod(
  17. '_setUp',
  18. smalltalk.method({
  19. selector: 'setUp',
  20. category: 'running',
  21. fn: function (){
  22. var self=this;
  23. self['@document']=unescape("%3Cdiv%20class%3D%22person%22%3E%0A%09%09%09%09%3Cul%3E%0A%09%09%09%09%09%3Cli%20class%3D%22firstname%22%3EJames%3C/li%3E%0A%09%09%09%09%09%3Cli%20class%3D%22lastname%22%3EBond%3C/li%3E%0A%09%09%09%09%3C/ul%3E%0A%09%09%09%3C/div%3E");
  24. return self;},
  25. source: unescape('setUp%0A%09document%20%3A%3D%20%27%3Cdiv%20class%3D%22person%22%3E%0A%09%09%09%09%3Cul%3E%0A%09%09%09%09%09%3Cli%20class%3D%22firstname%22%3EJames%3C/li%3E%0A%09%09%09%09%09%3Cli%20class%3D%22lastname%22%3EBond%3C/li%3E%0A%09%09%09%09%3C/ul%3E%0A%09%09%09%3C/div%3E%27.'),
  26. messageSends: [],
  27. referencedClasses: []
  28. }),
  29. smalltalk.JQueryTest);
  30. smalltalk.addMethod(
  31. '_testEach',
  32. smalltalk.method({
  33. selector: 'testEach',
  34. category: 'tests',
  35. fn: function (){
  36. var self=this;
  37. var classes=nil;
  38. classes=smalltalk.send(smalltalk.Array, "_new", []);
  39. smalltalk.send(smalltalk.send(smalltalk.send(self['@document'], "_asJQuery", []), "_find_", ["li"]), "_each_", [(function(index, element){return smalltalk.send(classes, "_add_", [smalltalk.send(smalltalk.send(smalltalk.JQuery, "_fromElement_", [element]), "_attr_", ["class"])]);})]);
  40. smalltalk.send(self, "_assert_equals_", [smalltalk.send(["firstname", "lastname"], "_printString", []), smalltalk.send(classes, "_printString", [])]);
  41. return self;},
  42. source: unescape('testEach%0A%09%7Cclasses%7C%0A%09classes%20%3A%3D%20Array%20new.%0A%0A%09%28document%20asJQuery%20find%3A%20%27li%27%29%20each%3A%20%5B%3Aindex%20%3Aelement%7C%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%09%09%20%20%09classes%20add%3A%20%28%28JQuery%20fromElement%3Aelement%29%20attr%3A%20%27class%27%29%5D.%0A%09self%20%0A%09%09assert%3A%20%23%28%27firstname%27%20%27lastname%27%29%20printString%0A%09%09equals%3A%20classes%20printString'),
  43. messageSends: ["new", "each:", "find:", "asJQuery", "add:", "attr:", "fromElement:", "assert:equals:", "printString"],
  44. referencedClasses: [smalltalk.Array,smalltalk.JQuery]
  45. }),
  46. smalltalk.JQueryTest);