Permalink
Browse files

Fixes #2134 - Merge branch 'specs' into fix-2134-merge-specs-submodule

Conflicts:
	.gitignore
	.gitmodules
  • Loading branch information...
2 parents fa2a8c8 + 4ebf266 commit f80ca2065f38bc6e356f30a47a630d2332c8f14f @arian arian committed Nov 29, 2011
Showing with 10,389 additions and 1 deletion.
  1. +3 −1 .gitignore
  2. +4 −0 .gitmodules
  3. +326 −0 Specs/1.2/Class/Class.Extras.js
  4. +247 −0 Specs/1.2/Class/Class.js
  5. +40 −0 Specs/1.2/Core/Browser.js
  6. +418 −0 Specs/1.2/Core/Core.js
  7. +69 −0 Specs/1.2/Core/Native.js
  8. +134 −0 Specs/1.2/Element/Element.Dimensions.js
  9. +87 −0 Specs/1.2/Element/Element.Style.js
  10. +1,568 −0 Specs/1.2/Element/Element.js
  11. +207 −0 Specs/1.2/Native/Array.js
  12. +155 −0 Specs/1.2/Native/Function.js
  13. +203 −0 Specs/1.2/Native/Hash.js
  14. +114 −0 Specs/1.2/Native/Number.js
  15. +158 −0 Specs/1.2/Native/String.js
  16. +17 −0 Specs/1.2/Utilities/Cookie.js
  17. +280 −0 Specs/1.3base/Class/Class.js
  18. +480 −0 Specs/1.3base/Core/Core.js
  19. +159 −0 Specs/1.3base/Fx/Fx.js
  20. +271 −0 Specs/1.3base/Types/Array.js
  21. +201 −0 Specs/1.3base/Types/Function.js
  22. +128 −0 Specs/1.3base/Types/Object.js
  23. +15 −0 Specs/1.3base/package.yml
  24. +20 −0 Specs/1.3client/Browser/Browser.js
  25. +183 −0 Specs/1.3client/Class/Class.Extras.js
  26. +56 −0 Specs/1.3client/Core/Core.js
  27. +86 −0 Specs/1.3client/Element/Element.Dimensions.js
  28. +85 −0 Specs/1.3client/Element/Element.Event.js
  29. +38 −0 Specs/1.3client/Element/Element.Style.js
  30. +360 −0 Specs/1.3client/Element/Element.js
  31. +32 −0 Specs/1.3client/Element/IFrame.js
  32. +128 −0 Specs/1.3client/Element/NewElement.js
  33. +58 −0 Specs/1.3client/Fx/Fx.Morph.js
  34. +127 −0 Specs/1.3client/Fx/Fx.Tween.js
  35. +254 −0 Specs/1.3client/Request/Request.HTML.js
  36. +64 −0 Specs/1.3client/Request/Request.JSON.js
  37. +140 −0 Specs/1.3client/Request/Request.js
  38. +29 −0 Specs/1.3client/Types/Object.js
  39. +25 −0 Specs/1.3client/Utilities/Cookie.js
  40. +33 −0 Specs/1.3client/Utilities/DOMReady.js
  41. +453 −0 Specs/1.3client/Utilities/DOMReady.php
  42. +33 −0 Specs/1.3client/Utilities/JSON.js
  43. +26 −0 Specs/1.3client/package.yml
  44. +29 −0 Specs/1.4base/Types/Array.js
  45. +32 −0 Specs/1.4base/Types/Function-nocompat.js
  46. +268 −0 Specs/1.4client/Element/Element.Delegation.html
  47. +58 −0 Specs/1.4client/Element/Element.Delegation.js
  48. +131 −0 Specs/1.4client/Element/Element.Event.change.html
  49. +85 −0 Specs/1.4client/Element/Element.Event.js
  50. +224 −0 Specs/1.4client/Element/Element.js
  51. +46 −0 Specs/1.4client/Fx/Fx.Tween.js
  52. +10 −0 Specs/1.4client/package.yml
  53. +572 −0 Specs/2.0base/Core/Core.js
  54. +291 −0 Specs/2.0base/Types/Array.js
  55. +232 −0 Specs/2.0base/Types/Function.js
  56. +132 −0 Specs/2.0base/Types/Number.js
  57. +176 −0 Specs/2.0base/Types/Object.js
  58. +149 −0 Specs/2.0base/Types/String.js
  59. +21 −0 Specs/2.0client/Browser/Browser.js
  60. +341 −0 Specs/Configuration.js
  61. +48 −0 Specs/README.md
  62. +1 −0 Specs/Runner
  63. +1 −0 Specs/buildMobile
  64. +28 −0 Specs/index.html
View
@@ -1,3 +1,5 @@
mootools-core.js
mootools-core.tmproj
-mootools-core.esproj
+mootools-core.esproj
+mootools-core-mobile.js
+*~
View
@@ -1,3 +1,7 @@
[submodule "Packager"]
path = Packager
url = git://github.com/kamicane/packager.git
+[submodule "Specs/Runner"]
+ path = Specs/Runner
+ url = git://github.com/mootools/mootools-runner.git
+
@@ -0,0 +1,326 @@
+/*
+Script: Class.Extras.js
+ Public specs for Class.Extras.js
+
+License:
+ MIT-style license.
+*/
+
+(function(){
+
+var Local = Local || {};
+
+describe("Chain Class", {
+
+ "before all": function(){
+ Local.Chain = new Class({
+
+ Implements: Chain
+
+ });
+ },
+
+ "callChain should not fail when nothing was added to the chain": function(){
+ var chain = new Local.Chain();
+ chain.callChain();
+ },
+
+ "should pass arguments to the function and return values": function(){
+ var chain = new Local.Chain();
+ var arr = [];
+ chain.chain(function(a, b){
+ var str = "0" + b + a;
+ arr.push(str);
+ return str;
+ });
+ chain.chain(function(a, b){
+ var str = "1" + b + a;
+ arr.push(str);
+ return str;
+ });
+ var ret;
+ expect(arr).toEqual([]);
+ ret = chain.callChain("a", "A");
+ expect(ret).toEqual("0Aa");
+ expect(arr).toEqual(["0Aa"]);
+
+ ret = chain.callChain("b", "B");
+ expect(ret).toEqual("1Bb");
+ expect(arr).toEqual(["0Aa", "1Bb"]);
+
+ ret = chain.callChain();
+ expect(ret).toEqual(false);
+ expect(arr).toEqual(["0Aa", "1Bb"]);
+ },
+
+ "should chain any number of functions": function(){
+ var chain = new Local.Chain();
+ var arr = [];
+
+ chain.chain(function(){
+ arr.push(0);
+ }, function(){
+ arr.push(1);
+ });
+
+ expect(arr).toEqual([]);
+ chain.callChain();
+ expect(arr).toEqual([0]);
+ chain.chain(function(){
+ arr.push(2);
+ });
+ chain.callChain();
+ expect(arr).toEqual([0, 1]);
+ chain.callChain();
+ expect(arr).toEqual([0, 1, 2]);
+ chain.callChain();
+ expect(arr).toEqual([0, 1, 2]);
+ },
+
+ "should allow an array of functions": function(){
+ var chain = new Local.Chain();
+ var arr = [];
+
+ chain.chain([function(){
+ arr.push(0);
+ }, function(){
+ arr.push(1);
+ }, function(){
+ arr.push(2);
+ }]);
+
+ expect(arr).toEqual([]);
+ chain.callChain();
+ expect(arr).toEqual([0]);
+ chain.callChain();
+ expect(arr).toEqual([0, 1]);
+ chain.callChain();
+ expect(arr).toEqual([0, 1, 2]);
+ chain.callChain();
+ expect(arr).toEqual([0, 1, 2]);
+ },
+
+ "each instance should have its own chain": function(){
+ var foo = new Local.Chain();
+ var bar = new Local.Chain();
+ foo.val = "F";
+ bar.val = "B";
+ foo.chain(function(){
+ this.val += 'OO';
+ });
+ bar.chain(function(){
+ this.val += 'AR';
+ });
+ expect(foo.val).toEqual('F');
+ expect(bar.val).toEqual('B');
+ foo.callChain();
+ bar.callChain();
+ expect(foo.val).toEqual('FOO');
+ expect(bar.val).toEqual('BAR');
+ },
+
+ "should be able to clear the chain": function(){
+ var called;
+ var fn = function(){
+ called = true;
+ };
+
+ var chain = new Local.Chain();
+ chain.chain(fn, fn, fn, fn);
+
+ chain.callChain();
+ expect(called).toBeTruthy();
+ called = false;
+
+ chain.clearChain();
+
+ chain.callChain();
+ expect(called).toBeFalsy();
+ called = false;
+ },
+
+ "should be able to clear the chain from within": function(){
+ var foo = new Local.Chain();
+
+ var test = 0;
+ foo.chain(function(){
+ test++;
+ foo.clearChain();
+ }).chain(function(){
+ test++;
+ }).callChain();
+
+ expect(test).toEqual(1);
+ }
+
+});
+
+var fire = 'fireEvent';
+
+var runEventSpecs = function(type, create){
+ describe('1.2 Events API: ' + type.capitalize(), {
+
+ 'before each': function(){
+ Local.called = 0;
+ Local.fn = function(){
+ return Local.called++;
+ };
+ },
+
+ 'should add an Event to the Class': function(){
+ var object = create();
+
+ object.addEvent('event', Local.fn)[fire]('event');
+
+ expect(Local.called).toEqual(1);
+ },
+
+ 'should add multiple Events to the Class': function(){
+ create().addEvents({
+ event1: Local.fn,
+ event2: Local.fn
+ })[fire]('event1')[fire]('event2');
+
+ expect(Local.called).toEqual(2);
+ },
+
+ // TODO 2.0only
+ /*'should be able to remove event during firing': function(){
+ create().addEvent('event', Local.fn).addEvent('event', function(){
+ Local.fn();
+ this.removeEvent('event', arguments.callee);
+ }).addEvent('event', function(){ Local.fn(); })[fire]('event')[fire]('event');
+
+ expect(Local.called).toEqual(5);
+ },*/
+
+ 'should remove a specific method for an event': function(){
+ var object = create();
+ var x = 0, fn = function(){ x++; };
+
+ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvent('event', Local.fn)[fire]('event');
+
+ expect(x).toEqual(1);
+ expect(Local.called).toEqual(0);
+ },
+
+ 'should remove an event and its methods': function(){
+ var object = create();
+ var x = 0, fn = function(){ x++; };
+
+ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvents('event')[fire]('event');
+
+ expect(x).toEqual(0);
+ expect(Local.called).toEqual(0);
+ },
+
+ 'should remove all events': function(){
+ var object = create();
+ var x = 0, fn = function(){ x++; };
+
+ object.addEvent('event1', Local.fn).addEvent('event2', fn).removeEvents();
+ object[fire]('event1')[fire]('event2');
+
+ expect(x).toEqual(0);
+ expect(Local.called).toEqual(0);
+ },
+
+ 'should remove events with an object': function(){
+ var object = create();
+ var events = {
+ event1: Local.fn,
+ event2: Local.fn
+ };
+
+ object.addEvent('event1', function(){ Local.fn(); }).addEvents(events)[fire]('event1');
+ expect(Local.called).toEqual(2);
+
+ object.removeEvents(events);
+ object[fire]('event1');
+ expect(Local.called).toEqual(3);
+
+ object[fire]('event2');
+ expect(Local.called).toEqual(3);
+ }
+
+ });
+};
+
+runEventSpecs('mixin', function(){
+ return new Events
+});
+
+runEventSpecs('element', function(){
+ return new Element('div');
+});
+
+describe("Options Class", {
+
+ "before all": function(){
+ Local.OptionsTest = new Class({
+ Implements: [Options, Events],
+
+ options: {
+ a: 1,
+ b: 2
+ },
+
+ initialize: function(options){
+ this.setOptions(options);
+ }
+ });
+ },
+
+ "should set options": function(){
+ var myTest = new Local.OptionsTest({a: 1, b: 3});
+ expect(myTest.options).not.toEqual(undefined);
+ },
+
+ "should override default options": function(){
+ var myTest = new Local.OptionsTest({a: 3, b: 4});
+ expect(myTest.options.a).toEqual(3);
+ expect(myTest.options.b).toEqual(4);
+ }
+
+});
+
+describe("Options Class with Events", {
+
+ "before all": function(){
+ Local.OptionsTest = new Class({
+ Implements: [Options, Events],
+
+ options: {
+ onEvent1: function(){
+ return true;
+ },
+ onEvent2: function(){
+ return false;
+ }
+ },
+
+ initialize: function(options){
+ this.setOptions(options);
+ }
+ });
+ },
+
+ "should add events in the options object if class has implemented the Events class": function(){
+ var myTest = new Local.OptionsTest({
+ onEvent2: function(){
+ return true;
+ },
+
+ onEvent3: function(){
+ return true;
+ }
+ });
+
+ expect(myTest.$events.event1.length).toEqual(1);
+ expect(myTest.$events.event2.length).toEqual(1);
+ expect(myTest.$events.event3.length).toEqual(1);
+ }
+
+});
+
+})();
Oops, something went wrong.

0 comments on commit f80ca20

Please sign in to comment.