From f5abbafc17eed4d18f5b384071797871e18c5132 Mon Sep 17 00:00:00 2001 From: Tim Wienk Date: Wed, 23 Sep 2015 15:25:47 +0200 Subject: [PATCH] Tests/Specs: Use Chai for assertions, instead of Jasmine's assertions. --- README.md | 2 +- Specs/Browser/Browser.js | 42 +- Specs/Class/Class.Extras.js | 92 ++-- Specs/Class/Class.js | 100 ++-- Specs/Core/Core.js | 371 +++++++------- Specs/Core/Native.js | 6 +- Specs/Core/Type.js | 6 +- Specs/Element/Element.Delegation.js | 10 +- Specs/Element/Element.Dimensions.js | 34 +- Specs/Element/Element.Event.js | 94 ++-- Specs/Element/Element.Style.js | 118 ++--- Specs/Element/Element.js | 948 ++++++++++++++++++------------------ Specs/Fx/Fx.Morph.js | 18 +- Specs/Fx/Fx.Tween.js | 32 +- Specs/Fx/Fx.js | 32 +- Specs/Request/Request.HTML.js | 92 ++-- Specs/Request/Request.JSON.js | 8 +- Specs/Request/Request.js | 36 +- Specs/Types/Array.js | 116 ++--- Specs/Types/Function.js | 168 ++++--- Specs/Types/Hash.js | 84 ++-- Specs/Types/Number.js | 46 +- Specs/Types/Object.js | 44 +- Specs/Types/String.js | 90 ++-- Specs/Utilities/Cookie.js | 6 +- Specs/Utilities/JSON.js | 12 +- Tests/gruntfile-options.js | 2 +- Tests/server-tests.js | 4 + package.json | 2 + 29 files changed, 1320 insertions(+), 1295 deletions(-) diff --git a/README.md b/README.md index 9b820f17..ee530138 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ a. __To report a bug:__ b. __To fix a bug:__ 1. Clone the repo. - 2. Add a [spec](http://jasmine.github.io/1.3/introduction.html). ([example](http://jsfiddle.net/q7RgN/)) + 2. Add a [spec](http://chaijs.com/guide/styles/#expect-section). 3. Fix the bug. 4. Build and run the specs. 5. Push to your GitHub fork. diff --git a/Specs/Browser/Browser.js b/Specs/Browser/Browser.js index 69540a8d..3613d650 100644 --- a/Specs/Browser/Browser.js +++ b/Specs/Browser/Browser.js @@ -11,11 +11,11 @@ describe('$exec', function(){ it('should evaluate on global scope', function(){ $exec.call($exec, 'var execSpec = 42'); - expect(window.execSpec).toEqual(42); + expect(window.execSpec).to.equal(42); }); it('should return the evaluated script', function(){ - expect($exec('$empty();')).toEqual('$empty();'); + expect($exec('$empty();')).to.equal('$empty();'); }); }); @@ -25,11 +25,11 @@ describe('Browser.exec', function(){ it('should evaluate on global scope', function(){ Browser.exec.call(Browser.exec, 'var execSpec = 42'); - expect(window.execSpec).toEqual(42); + expect(window.execSpec).to.equal(42); }); it('should return the evaluated script', function(){ - expect(Browser.exec('function test(){}')).toEqual('function test(){}'); + expect(Browser.exec('function test(){}')).to.equal('function test(){}'); }); }); @@ -39,16 +39,16 @@ describe('Browser.exec', function(){ describe('String.stripScripts', function(){ it('should strip all script tags from a string', function(){ - expect('
'.stripScripts()).toEqual('
'); + expect('
'.stripScripts()).to.equal('
'); }); it('should execute the stripped tags from the string', function(){ - expect('
'.stripScripts(true)).toEqual('
'); - expect(window.stripScriptsSpec).toEqual(42); - expect('
'.stripScripts(true)).toEqual('
'); - expect(window.stripScriptsSpec).toEqual(24); - expect('
'.stripScripts(true)).toEqual('
'); - expect(window.stripScriptsSpec).toEqual(4242); + expect('
'.stripScripts(true)).to.equal('
'); + expect(window.stripScriptsSpec).to.equal(42); + expect('
'.stripScripts(true)).to.equal('
'); + expect(window.stripScriptsSpec).to.equal(24); + expect('
'.stripScripts(true)).to.equal('
'); + expect(window.stripScriptsSpec).to.equal(4242); }); }); @@ -57,11 +57,11 @@ describe('String.stripScripts', function(){ describe('Document', function(){ it('should hold the parent window', function(){ - expect(document.window).toEqual(window); + expect(document.window).to.equal(window); }); it('should hold the head element', function(){ - expect(document.head.tagName.toLowerCase()).toEqual('head'); + expect(document.head.tagName.toLowerCase()).to.equal('head'); }); }); @@ -69,7 +69,7 @@ describe('Document', function(){ describe('Window', function(){ it('should set the Element prototype', function(){ - expect(window.Element.prototype).toBeDefined(); + expect(window.Element.prototype).to.not.equal(undefined); }); }); @@ -78,29 +78,29 @@ describe('Browser', function(){ var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i); it('should think it is executed in a browser', function(){ - if (!isPhantomJS) expect(['ie', 'safari', 'chrome', 'firefox', 'opera', 'edge']).toContain(Browser.name); + if (!isPhantomJS) expect(['ie', 'safari', 'chrome', 'firefox', 'opera', 'edge']).to.contain(Browser.name); }); //<1.4compat> it('should assign a Browser[Browser.name] property for all browsers, except IE v11 or higher', function(){ if (Browser.name != 'ie' || Browser.version < 11){ - expect(isPhantomJS || Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera || Browser.edge).toEqual(true); + expect(isPhantomJS || Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera || Browser.edge).to.equal(true); } }); it('should not assign a Browser[Browser.name] property for IE v11 or higher', function(){ if (Browser.name == 'ie' && Browser.version >= 11){ - expect(Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera || Browser.edge).toBeUndefined(); + expect(Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera || Browser.edge).to.equal(undefined); } }); // it('should assume the IE version is emulated by the documentMode (X-UA-Compatible)', function(){ - if (Browser.name == 'ie' && document.documentMode) expect(Browser.version).toEqual(document.documentMode); + if (Browser.name == 'ie' && document.documentMode) expect(Browser.version).to.equal(document.documentMode); }); it('should find a browser version', function(){ - expect(Browser.version || isPhantomJS).toBeTruthy(); - expect(typeof Browser.version).toEqual('number'); + expect(Browser.version || isPhantomJS).to.be.ok; + expect(typeof Browser.version).to.equal('number'); }); }); @@ -248,7 +248,7 @@ describe('Browser.parseUA', function(){ }; var runExpects = function(val, key){ - expect(this[key]).toEqual(val); + expect(this[key]).to.equal(val); }; Object.forEach(userAgents, function(obj){ diff --git a/Specs/Class/Class.Extras.js b/Specs/Class/Class.Extras.js index eb21cdd4..66db75fe 100644 --- a/Specs/Class/Class.Extras.js +++ b/Specs/Class/Class.Extras.js @@ -35,18 +35,18 @@ describe('Chain', function(){ return str; }); var ret; - expect(arr).toEqual([]); + expect(arr).to.deep.equal([]); ret = chain.callChain("a", "A"); - expect(ret).toEqual("0Aa"); - expect(arr).toEqual(["0Aa"]); + expect(ret).to.equal("0Aa"); + expect(arr).to.deep.equal(["0Aa"]); ret = chain.callChain("b", "B"); - expect(ret).toEqual("1Bb"); - expect(arr).toEqual(["0Aa", "1Bb"]); + expect(ret).to.equal("1Bb"); + expect(arr).to.deep.equal(["0Aa", "1Bb"]); ret = chain.callChain(); - expect(ret).toEqual(false); - expect(arr).toEqual(["0Aa", "1Bb"]); + expect(ret).to.equal(false); + expect(arr).to.deep.equal(["0Aa", "1Bb"]); }); it('should chain any number of functions', function(){ @@ -59,18 +59,18 @@ describe('Chain', function(){ arr.push(1); }); - expect(arr).toEqual([]); + expect(arr).to.deep.equal([]); chain.callChain(); - expect(arr).toEqual([0]); + expect(arr).to.deep.equal([0]); chain.chain(function(){ arr.push(2); }); chain.callChain(); - expect(arr).toEqual([0, 1]); + expect(arr).to.deep.equal([0, 1]); chain.callChain(); - expect(arr).toEqual([0, 1, 2]); + expect(arr).to.deep.equal([0, 1, 2]); chain.callChain(); - expect(arr).toEqual([0, 1, 2]); + expect(arr).to.deep.equal([0, 1, 2]); }); it('should allow an array of functions', function(){ @@ -85,15 +85,15 @@ describe('Chain', function(){ arr.push(2); }]); - expect(arr).toEqual([]); + expect(arr).to.deep.equal([]); chain.callChain(); - expect(arr).toEqual([0]); + expect(arr).to.deep.equal([0]); chain.callChain(); - expect(arr).toEqual([0, 1]); + expect(arr).to.deep.equal([0, 1]); chain.callChain(); - expect(arr).toEqual([0, 1, 2]); + expect(arr).to.deep.equal([0, 1, 2]); chain.callChain(); - expect(arr).toEqual([0, 1, 2]); + expect(arr).to.deep.equal([0, 1, 2]); }); it('each instance should have its own chain', function(){ @@ -107,12 +107,12 @@ describe('Chain', function(){ bar.chain(function(){ this.val += 'AR'; }); - expect(foo.val).toEqual('F'); - expect(bar.val).toEqual('B'); + expect(foo.val).to.equal('F'); + expect(bar.val).to.equal('B'); foo.callChain(); bar.callChain(); - expect(foo.val).toEqual('FOO'); - expect(bar.val).toEqual('BAR'); + expect(foo.val).to.equal('FOO'); + expect(bar.val).to.equal('BAR'); }); it('should be able to clear the chain', function(){ @@ -125,13 +125,13 @@ describe('Chain', function(){ chain.chain(fn, fn, fn, fn); chain.callChain(); - expect(called).toBeTruthy(); + expect(called).to.equal(true); called = false; chain.clearChain(); chain.callChain(); - expect(called).toBeFalsy(); + expect(called).to.equal(false); called = false; }); @@ -146,7 +146,7 @@ describe('Chain', function(){ test++; }).callChain(); - expect(test).toEqual(1); + expect(test).to.equal(1); }); }); @@ -169,7 +169,7 @@ describe('Events API: Mixin', function(){ object.addEvent('event', Local.fn)[fire]('event'); - expect(Local.called).toEqual(1); + expect(Local.called).to.equal(1); }); it('should add multiple Events to the Class', function(){ @@ -178,7 +178,7 @@ describe('Events API: Mixin', function(){ event2: Local.fn })[fire]('event1')[fire]('event2'); - expect(Local.called).toEqual(2); + expect(Local.called).to.equal(2); }); it('should remove a specific method for an event', function(){ @@ -187,8 +187,8 @@ describe('Events API: Mixin', function(){ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvent('event', Local.fn)[fire]('event'); - expect(x).toEqual(1); - expect(Local.called).toEqual(0); + expect(x).to.equal(1); + expect(Local.called).to.equal(0); }); it('should remove an event and its methods', function(){ @@ -197,8 +197,8 @@ describe('Events API: Mixin', function(){ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvents('event')[fire]('event'); - expect(x).toEqual(0); - expect(Local.called).toEqual(0); + expect(x).to.equal(0); + expect(Local.called).to.equal(0); }); it('should remove all events', function(){ @@ -211,8 +211,8 @@ describe('Events API: Mixin', function(){ // Should not fail object.removeEvents()[fire]('event1')[fire]('event2'); - expect(x).toEqual(0); - expect(Local.called).toEqual(0); + expect(x).to.equal(0); + expect(Local.called).to.equal(0); }); it('should remove events with an object', function(){ @@ -223,14 +223,14 @@ describe('Events API: Mixin', function(){ }; object.addEvent('event1', function(){ Local.fn(); }).addEvents(events)[fire]('event1'); - expect(Local.called).toEqual(2); + expect(Local.called).to.equal(2); object.removeEvents(events); object[fire]('event1'); - expect(Local.called).toEqual(3); + expect(Local.called).to.equal(3); object[fire]('event2'); - expect(Local.called).toEqual(3); + expect(Local.called).to.equal(3); }); it('should remove an event immediately', function(){ @@ -250,10 +250,10 @@ describe('Events API: Mixin', function(){ }).addEvent('event', three); object[fire]('event'); - expect(methods).toEqual([1, 2]); + expect(methods).to.deep.equal([1, 2]); object[fire]('event'); - expect(methods).toEqual([1, 2, 1, 2]); + expect(methods).to.deep.equal([1, 2, 1, 2]); }); it('should be able to remove itself', function(){ @@ -276,10 +276,10 @@ describe('Events API: Mixin', function(){ object.addEvent('event', one).addEvent('event', two).addEvent('event', three); object[fire]('event'); - expect(methods).toEqual([1, 2, 3]); + expect(methods).to.deep.equal([1, 2, 3]); object[fire]('event'); - expect(methods).toEqual([1, 2, 3, 3]); + expect(methods).to.deep.equal([1, 2, 3, 3]); }); }); @@ -301,13 +301,13 @@ describe('Options Class', function(){ it('should set options', function(){ var myTest = new Local.OptionsTest({a: 1, b: 3}); - expect(myTest.options).not.toEqual(undefined); + expect(myTest.options).to.not.equal(undefined); }); it('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); + expect(myTest.options.a).to.equal(3); + expect(myTest.options.b).to.equal(4); }); }); @@ -344,9 +344,9 @@ describe('Options Class with Events', function(){ } }); - expect(myTest.$events.event1.length).toEqual(1); - expect(myTest.$events.event2.length).toEqual(1); - expect(myTest.$events.event3.length).toEqual(1); + expect(myTest.$events.event1.length).to.equal(1); + expect(myTest.$events.event2.length).to.equal(1); + expect(myTest.$events.event3.length).to.equal(1); }); }); @@ -366,7 +366,7 @@ describe('setOptions', function(){ }); - expect(new A({document: document}).options.document == document).toBeTruthy(); + expect(new A({document: document}).options.document).to.equal(document); }); }); diff --git a/Specs/Class/Class.js b/Specs/Class/Class.js index 21b3b7e9..562f4dff 100644 --- a/Specs/Class/Class.js +++ b/Specs/Class/Class.js @@ -93,40 +93,40 @@ describe('Class creation', function(){ //<1.2compat> it("Classes should be of type 'class'", function(){ - expect($type(Animal)).toEqual('class'); - expect(Class.type(Animal)).toBeTruthy(); + expect($type(Animal)).to.equal('class'); + expect(Class.type(Animal)).to.equal(true); }); // it("Classes should be of type 'class'", function(){ - expect(typeOf(Animal)).toEqual('class'); + expect(typeOf(Animal)).to.equal('class'); }); it('should call initialize upon instantiation', function(){ var animal = new Animal('lamina'); - expect(animal.name).toEqual('lamina'); - expect(animal.initialized).toBeTruthy(); - expect(animal.say()).toEqual('animal:say:lamina'); + expect(animal.name).to.equal('lamina'); + expect(animal.initialized).to.equal(true); + expect(animal.say()).to.equal('animal:say:lamina'); }); it("should use 'Extend' property to extend another class", function(){ var cat = new Cat('fluffy'); - expect(cat.name).toEqual('fluffy'); - expect(cat.sound).toEqual('miao'); - expect(cat.ferocious).toBeFalsy(); - expect(cat.say()).toEqual('animal:say:fluffy'); - expect(cat.eat()).toEqual('cat:eat:fluffy'); - expect(cat.play()).toEqual('cat:play:fluffy'); + expect(cat.name).to.equal('fluffy'); + expect(cat.sound).to.equal('miao'); + expect(cat.ferocious).to.equal(false); + expect(cat.say()).to.equal('animal:say:fluffy'); + expect(cat.eat()).to.equal('cat:eat:fluffy'); + expect(cat.play()).to.equal('cat:play:fluffy'); }); it("should use 'Extend' property to extend an extended class", function(){ var leo = new Lion('leo'); - expect(leo.name).toEqual('leo'); - expect(leo.sound).toEqual('rarr'); - expect(leo.ferocious).toBeTruthy(); - expect(leo.say()).toEqual('animal:say:leo'); - expect(leo.eat()).toEqual('lion:eat:leo'); - expect(leo.play()).toEqual('cat:play:leo'); + expect(leo.name).to.equal('leo'); + expect(leo.sound).to.equal('rarr'); + expect(leo.ferocious).to.equal(true); + expect(leo.say()).to.equal('animal:say:leo'); + expect(leo.eat()).to.equal('lion:eat:leo'); + expect(leo.play()).to.equal('cat:play:leo'); }); it("should use 'Implements' property to implement another class", function(){ @@ -135,9 +135,9 @@ describe('Class creation', function(){ }); var rover = new Dog('rover'); - expect(rover.name).toEqual('rover'); - expect(rover.initialized).toBeTruthy(); - expect(rover.eat()).toEqual('animal:eat:rover'); + expect(rover.name).to.equal('rover'); + expect(rover.initialized).to.equal(true); + expect(rover.eat()).to.equal('animal:eat:rover'); }); it("should use 'Implements' property to implement any number of classes", function(){ @@ -147,13 +147,13 @@ describe('Class creation', function(){ }); var rover = new Dog('rover'); - expect(rover.initialized).toBeTruthy(); - expect(rover.eat()).toEqual('animal:eat:rover'); - expect(rover.say()).toEqual('animal:say:rover'); - expect(rover.jump()).toEqual('actions:jump:rover'); - expect(rover.sleep()).toEqual('actions:sleep:rover'); - expect(rover.size()).toEqual('attributes:size:rover'); - expect(rover.color()).toEqual('attributes:color:rover'); + expect(rover.initialized).to.equal(true); + expect(rover.eat()).to.equal('animal:eat:rover'); + expect(rover.say()).to.equal('animal:say:rover'); + expect(rover.jump()).to.equal('actions:jump:rover'); + expect(rover.sleep()).to.equal('actions:sleep:rover'); + expect(rover.size()).to.equal('attributes:size:rover'); + expect(rover.color()).to.equal('attributes:color:rover'); }); it("should alter the Class's prototype when implementing new methods", function(){ @@ -171,8 +171,8 @@ describe('Class creation', function(){ var spot = new Dog('spot'); - expect(spot.jump()).toEqual('dog:jump:spot'); - expect(rover.jump()).toEqual('dog:jump:rover'); + expect(spot.jump()).to.equal('dog:jump:spot'); + expect(rover.jump()).to.equal('dog:jump:rover'); }); it("should alter the Class's prototype when implementing new methods into the super class", function(){ @@ -190,8 +190,8 @@ describe('Class creation', function(){ var spot = new Dog('spot'); - expect(spot.jump()).toEqual('animal:jump:spot'); - expect(rover.jump()).toEqual('animal:jump:rover'); + expect(spot.jump()).to.equal('animal:jump:spot'); + expect(rover.jump()).to.equal('animal:jump:rover'); }); it("should alter the Class's prototype when overwriting methods in the super class", function(){ @@ -200,7 +200,7 @@ describe('Class creation', function(){ }); var rover = new Dog('rover'); - expect(rover.say()).toEqual('animal:say:rover'); + expect(rover.say()).to.equal('animal:say:rover'); Animal.implement({ say: function(){ @@ -210,8 +210,8 @@ describe('Class creation', function(){ var spot = new Dog('spot'); - expect(spot.say()).toEqual('NEW:animal:say:spot'); - expect(rover.say()).toEqual('NEW:animal:say:rover'); + expect(spot.say()).to.equal('NEW:animal:say:spot'); + expect(rover.say()).to.equal('NEW:animal:say:rover'); }); }); @@ -227,9 +227,9 @@ describe('Class::implement', function(){ var rover = new Dog('rover'); - expect(rover.name).toEqual('rover'); - expect(rover.jump()).toEqual('actions:jump:rover'); - expect(rover.sleep()).toEqual('actions:sleep:rover'); + expect(rover.name).to.equal('rover'); + expect(rover.jump()).to.equal('actions:jump:rover'); + expect(rover.sleep()).to.equal('actions:sleep:rover'); }); it('should implement any number of objects', function(){ @@ -241,11 +241,11 @@ describe('Class::implement', function(){ var rover = new Dog('rover'); - expect(rover.name).toEqual('rover'); - expect(rover.jump()).toEqual('actions:jump:rover'); - expect(rover.sleep()).toEqual('actions:sleep:rover'); - expect(rover.size()).toEqual('attributes:size:rover'); - expect(rover.color()).toEqual('attributes:color:rover'); + expect(rover.name).to.equal('rover'); + expect(rover.jump()).to.equal('actions:jump:rover'); + expect(rover.sleep()).to.equal('actions:sleep:rover'); + expect(rover.size()).to.equal('attributes:size:rover'); + expect(rover.color()).to.equal('attributes:color:rover'); }); }); @@ -275,9 +275,9 @@ describe('Class toString', function(){ }); - expect((new Person('Valerio')) + '').toBe('Valerio'); + expect((new Person('Valerio')) + '').to.equal('Valerio'); - expect((new Italian('Valerio')) + '').toBe("It's me, Valerio"); + expect((new Italian('Valerio')) + '').to.equal("It's me, Valerio"); }); }); @@ -326,23 +326,23 @@ describe('Class.toElement', function(){ var element = new Element('div', {'class': 'my-element'}); var instance = new MyParentElement(element); - expect(document.id(instance)).toBe(element); + expect(document.id(instance)).to.equal(element); }); dit('should call the toElement() method in parent class if none is defined in child', function(){ var element = new Element('div', {'class': 'my-element'}); var instance = new MyChildElement(element); - expect(document.id(instance)).toBe(element); - expect(instance instanceof MyParentElement).toEqual(true); + expect(document.id(instance)).to.equal(element); + expect(instance instanceof MyParentElement).to.equal(true); }); dit('should call toElement() when extending natives (String, Array, Object)', function(){ var element = new Element('div', {'class': 'my-element'}); var instance = new MyArrayElement(element); - expect(document.id(instance)).toBe(element); - expect(instance instanceof Array).toEqual(true); + expect(document.id(instance)).to.equal(element); + expect(instance instanceof Array).to.equal(true); }); }); diff --git a/Specs/Core/Core.js b/Specs/Core/Core.js index a3900e48..cce41faf 100644 --- a/Specs/Core/Core.js +++ b/Specs/Core/Core.js @@ -12,7 +12,7 @@ describe('$A', function(){ it('should return a copy for an array', function(){ var arr1 = [1,2,3]; var arr2 = $A(arr1); - expect(arr1 !== arr2).toBeTruthy(); + expect(arr1).to.not.equal(arr2); }); it('should return an array for an Elements collection', function(){ @@ -24,7 +24,7 @@ describe('$A', function(){ div1.appendChild(div3); var array = $A(div1.getElementsByTagName('*')); - expect(Array.type(array)).toBeTruthy(); + expect(Array.type(array)).to.equal(true); }); it('should return an array for arguments', function(){ @@ -32,8 +32,8 @@ describe('$A', function(){ return $A(arguments); }; var arr = fnTest(1,2,3); - expect(Array.type(arr)).toBeTruthy(); - expect(arr.length).toEqual(3); + expect(Array.type(arr)).to.equal(true); + expect(arr.length).to.equal(3); }); }); @@ -41,10 +41,10 @@ describe('$A', function(){ describe('$arguments', function(){ it('should return the argument passed according to the index', function(){ - expect($arguments(0)('a','b','c','d')).toEqual('a'); - expect($arguments(1)('a','b','c','d')).toEqual('b'); - expect($arguments(2)('a','b','c','d')).toEqual('c'); - expect($arguments(3)('a','b','c','d')).toEqual('d'); + expect($arguments(0)('a','b','c','d')).to.equal('a'); + expect($arguments(1)('a','b','c','d')).to.equal('b'); + expect($arguments(2)('a','b','c','d')).to.equal('c'); + expect($arguments(3)('a','b','c','d')).to.equal('d'); }); }); @@ -52,25 +52,25 @@ describe('$arguments', function(){ describe('$chk', function(){ it('should return false on false', function(){ - expect($chk(false)).toBeFalsy(); + expect($chk(false)).to.equal(false); }); it('should return false on null', function(){ - expect($chk(null)).toBeFalsy(); + expect($chk(null)).to.equal(false); }); it('should return false on undefined', function(){ - expect($chk(undefined)).toBeFalsy(); + expect($chk(undefined)).to.equal(false); }); it('should return true on 0', function(){ - expect($chk(0)).toBeTruthy(); + expect($chk(0)).to.equal(true); }); it('should return true for any truthsie', function(){ - expect($chk(1)).toBeTruthy(); - expect($chk({})).toBeTruthy(); - expect($chk(true)).toBeTruthy(); + expect($chk(1)).to.equal(true); + expect($chk({})).to.equal(true); + expect($chk(true)).to.equal(true); }); }); @@ -79,12 +79,12 @@ describe('$clear', function(){ it('should clear timeouts', function(){ var timeout = setTimeout(function(){}, 100); - expect($clear(timeout)).toBeNull(); + expect($clear(timeout)).to.equal(null); }); it('should clear intervals', function(){ var interval = setInterval(function(){}, 100); - expect($clear(interval)).toBeNull(); + expect($clear(interval)).to.equal(null); }); }); @@ -92,19 +92,19 @@ describe('$clear', function(){ describe('$defined', function(){ it('should return true on 0', function(){ - expect($defined(0)).toBeTruthy(); + expect($defined(0)).to.equal(true); }); it('should return true on false', function(){ - expect($defined(false)).toBeTruthy(); + expect($defined(false)).to.equal(true); }); it('should return false on null', function(){ - expect($defined(null)).toBeFalsy(); + expect($defined(null)).to.equal(false); }); it('should return false on undefined', function(){ - expect($defined(undefined)).toBeFalsy(); + expect($defined(undefined)).to.equal(false); }); }); @@ -119,7 +119,7 @@ describe('$each', function(){ }); })('Sun','Mon','Tue'); - expect(daysArr).toEqual(['Sun','Mon','Tue']); + expect(daysArr).to.deep.equal(['Sun','Mon','Tue']); }); it('should call the function for each item in the array', function(){ @@ -128,7 +128,7 @@ describe('$each', function(){ daysArr[key] = value; }); - expect(daysArr).toEqual(['Sun','Mon','Tue']); + expect(daysArr).to.deep.equal(['Sun','Mon','Tue']); }); it('should call the function for each item in the object', function(){ @@ -137,7 +137,7 @@ describe('$each', function(){ daysObj[key] = value; }); - expect(daysObj).toEqual({first: 'Sunday', second: 'Monday', third: 'Tuesday'}); + expect(daysObj).to.deep.equal({first: 'Sunday', second: 'Monday', third: 'Tuesday'}); }); }); @@ -148,20 +148,20 @@ describe('$extend', function(){ var obj1 = {a: 1, b: 2}; var obj2 = {b: 3, c: 4}; $extend(obj1, obj2); - expect(obj1).toEqual({a: 1, b: 3, c: 4}); + expect(obj1).to.deep.equal({a: 1, b: 3, c: 4}); }); it('should overwrite properties', function(){ var obj1 = {a: 1, b: 2}; var obj2 = {b: 3, c: 4, a: 5}; $extend(obj1, obj2); - expect(obj1).toEqual({a: 5, b: 3, c: 4}); + expect(obj1).to.deep.equal({a: 5, b: 3, c: 4}); }); it('should not extend with null argument', function(){ var obj1 = {a: 1, b: 2}; $extend(obj1); - expect(obj1).toEqual({a: 1, b: 2}); + expect(obj1).to.deep.equal({a: 1, b: 2}); }); }); @@ -170,11 +170,11 @@ describe('$lambda', function(){ it('if a function is passed in that function should be returned', function(){ var fn = function(a,b){ return a; }; - expect($lambda(fn)).toEqual(fn); + expect($lambda(fn)).to.equal(fn); }); it('should return a function that returns the value passed when called', function(){ - expect($lambda('hello world!')()).toEqual('hello world!'); + expect($lambda('hello world!')()).to.equal('hello world!'); }); }); @@ -184,14 +184,14 @@ describe('$merge', function(){ it('should dereference objects', function(){ var obj1 = {a: 1, b: 2}; var obj2 = $merge(obj1); - expect(obj1 === obj2).toBeFalsy(); + expect(obj1).to.not.equal(obj2); }); it('should merge any arbitrary number of nested objects', function(){ var obj1 = {a: {a: 1, b: 2, c: 3}, b: 2}; var obj2 = {a: {a: 2, b: 8, c: 3, d: 8}, b: 3, c: 4}; var obj3 = {a: {a: 3}, b: 3, c: false}; - expect($merge(obj1, obj2, obj3)).toEqual({a: {a: 3, b: 8, c: 3, d: 8}, b: 3, c: false}); + expect($merge(obj1, obj2, obj3)).to.deep.equal({a: {a: 3, b: 8, c: 3, d: 8}, b: 3, c: false}); }); }); @@ -200,12 +200,12 @@ describe('$pick', function(){ it('should return the first false argument', function(){ var picked1 = $pick(null, undefined, false, [1,2,3], {}); - expect(picked1).toBeFalsy(); + expect(picked1).to.equal(false); }); it('should return the first defined argument', function(){ var picked1 = $pick(null, undefined, null, [1,2,3], {}); - expect(picked1).toEqual([1,2,3]); + expect(picked1).to.deep.equal([1,2,3]); }); }); @@ -214,7 +214,8 @@ describe('$random', function(){ it('should return a number between two numbers specified', function(){ var rand = $random(1, 3); - expect((rand <= 3 && rand >= 1)).toBeTruthy(); + expect(rand).to.be.at.least(1); + expect(rand).to.be.at.most(3); }); }); @@ -222,16 +223,16 @@ describe('$random', function(){ describe('$splat', function(){ it('should transform a non array into an array', function(){ - expect($splat(1)).toEqual([1]); + expect($splat(1)).to.deep.equal([1]); }); it('should transforum an undefined or null into an empty array', function(){ - expect($splat(null)).toEqual([]); - expect($splat(undefined)).toEqual([]); + expect($splat(null)).to.deep.equal([]); + expect($splat(undefined)).to.deep.equal([]); }); it('should ignore and return an array', function(){ - expect($splat([1,2,3])).toEqual([1,2,3]); + expect($splat([1,2,3])).to.deep.equal([1,2,3]); }); }); @@ -239,11 +240,13 @@ describe('$splat', function(){ describe('$time', function(){ it('should return a timestamp', function(){ - expect(Number.type($time())).toBeTruthy(); + expect(Number.type($time())).to.equal(true); }); it('should be within a reasonable range', function(){ - expect($time() < 1e13 && $time() > 1e12).toBeTruthy(); + var time = $time(); + expect(time).to.be.greaterThan(1e12); + expect(time).to.be.lessThan(1e13); }); }); @@ -262,8 +265,8 @@ describe('$try', function(){ calls++; return 'moo'; }); - expect(calls).toEqual(2); - expect(attempt).toEqual('success'); + expect(calls).to.equal(2); + expect(attempt).to.equal('success'); }); it('should return null when no function succeeded', function(){ @@ -275,8 +278,8 @@ describe('$try', function(){ calls++; return uninstall_ie(); }); - expect(calls).toEqual(2); - expect(attempt).toBeNull(); + expect(calls).to.equal(2); + expect(attempt).to.equal(null); }); }); @@ -285,72 +288,72 @@ describe('$try', function(){ describe('$type', function(){ it("should return 'array' for Array objects", function(){ - expect($type([1,2])).toEqual('array'); + expect($type([1,2])).to.equal('array'); }); it("should return 'string' for String objects", function(){ - expect($type('ciao')).toEqual('string'); + expect($type('ciao')).to.equal('string'); }); it("should return 'regexp' for RegExp objects", function(){ - expect($type(/_/)).toEqual('regexp'); + expect($type(/_/)).to.equal('regexp'); }); it("should return 'function' for Function objects", function(){ - expect($type(function(){})).toEqual('function'); + expect($type(function(){})).to.equal('function'); }); it("should return 'number' for Number objects", function(){ - expect($type(10)).toEqual('number'); - expect($type(NaN)).not.toEqual('number'); + expect($type(10)).to.equal('number'); + expect($type(NaN)).to.not.equal('number'); }); it("should return 'boolean' for Boolean objects", function(){ - expect($type(true)).toEqual('boolean'); - expect($type(false)).toEqual('boolean'); + expect($type(true)).to.equal('boolean'); + expect($type(false)).to.equal('boolean'); }); it("should return 'object' for Object objects", function(){ - expect($type({a:2})).toEqual('object'); + expect($type({a:2})).to.equal('object'); }); it("should return 'arguments' for Function arguments", function(){ if (window.opera){ // Seems like the Opera guys can't decide on this var type = $type(arguments); - expect(type == 'array' || type == 'arguments').toBeTruthy(); + expect(type == 'array' || type == 'arguments').to.equal(true); return; } - expect($type(arguments)).toEqual('arguments'); + expect($type(arguments)).to.equal('arguments'); }); it("should return false for null objects", function(){ - expect($type(null)).toBeFalsy(); + expect($type(null)).to.equal(false); }); it("should return false for undefined objects", function(){ - expect($type(undefined)).toBeFalsy(); + expect($type(undefined)).to.equal(false); }); it("should return 'collection' for HTMLElements collections", function(){ - expect($type(document.getElementsByTagName('*'))).toEqual('collection'); + expect($type(document.getElementsByTagName('*'))).to.equal('collection'); }); it("should return 'element' for an Element", function(){ var div = document.createElement('div'); - expect($type(div)).toEqual('element'); + expect($type(div)).to.equal('element'); }); it("should return 'array' for Elements", function(){ - expect($type(new Elements)).toEqual('array'); + expect($type(new Elements)).to.equal('array'); }); it("should return 'window' for the window object", function(){ - expect($type(window)).toEqual('window'); + expect($type(window)).to.equal('window'); }); it("should return 'document' for the document object", function(){ - expect($type(document)).toEqual('document'); + expect($type(document)).to.equal('document'); }); }); @@ -364,26 +367,26 @@ describe('$unlink', function(){ obj.a = 10; inner.b = 20; - expect(obj.a).toEqual(10); - expect(obj.inner.b).toEqual(20); - expect($type(obj)).toEqual('object'); + expect(obj.a).to.equal(10); + expect(obj.inner.b).to.equal(20); + expect($type(obj)).to.equal('object'); - expect(copy.a).toEqual(1); - expect(copy.inner.b).toEqual(2); - expect($type(copy)).toEqual('object'); + expect(copy.a).to.equal(1); + expect(copy.inner.b).to.equal(2); + expect($type(copy)).to.equal('object'); }); it("should unlink an Hash", function(){ var hash = new Hash({a: 'one'}); var copy = $unlink(hash); - expect($type(hash)).toEqual('hash'); - expect($type(copy)).toEqual('hash'); + expect($type(hash)).to.equal('hash'); + expect($type(copy)).to.equal('hash'); copy.set('a', 'two'); - expect(hash.get('a')).toEqual('one'); - expect(copy.get('a')).toEqual('two'); + expect(hash.get('a')).to.equal('one'); + expect(copy.get('a')).to.equal('two'); }); }); @@ -392,20 +395,20 @@ describe('Hash.getLength', function(){ it("should return the number of items in it", function(){ var hash = new Hash({}); - expect(hash.getLength()).toEqual(0); + expect(hash.getLength()).to.equal(0); hash.set('mootools', 'awesome'); hash.milk = 'yummy'; - expect(hash.getLength()).toEqual(2); + expect(hash.getLength()).to.equal(2); }); it("should not fail when length is set", function(){ var hash = new Hash({'length': 10}); - expect(hash.getLength()).toEqual(1); + expect(hash.getLength()).to.equal(1); }); it("should work as a generic on objects", function(){ - expect(Hash.getLength({})).toEqual(0); - expect(Hash.getLength({'': '', '0': '0', 'length': 99})).toEqual(3); + expect(Hash.getLength({})).to.equal(0); + expect(Hash.getLength({'': '', '0': '0', 'length': 99})).to.equal(3); }); }); @@ -414,7 +417,7 @@ describe('$H', function(){ it("should create a new hash", function(){ var hash = $H({}); - expect($type(hash)).toEqual('hash'); + expect($type(hash)).to.equal('hash'); }); }); @@ -436,14 +439,14 @@ describe('Function.prototype.overloadSetter', function(){ setter = setter.overloadSetter(); setter('key', 'value'); - expect(collector).toEqual({key: 'value'}); + expect(collector).to.deep.equal({key: 'value'}); setter({ otherKey: 1, property: 2 }); - expect(collector).toEqual({ + expect(collector).to.deep.equal({ key: 'value', otherKey: 1, property: 2 @@ -454,7 +457,7 @@ describe('Function.prototype.overloadSetter', function(){ }); setter('otherKey', 4); - expect(collector).toEqual({ + expect(collector).to.deep.equal({ key: 3, otherKey: 4, property: 2 @@ -469,7 +472,7 @@ describe('Function.prototype.overloadSetter', function(){ c: 'd' }); - expect(collector).toEqual({ + expect(collector).to.deep.equal({ a: 'b', c: 'd' }); @@ -495,24 +498,24 @@ describe('Function.prototype.overloadGetter', function(){ it('should call a getter for each argument', function(){ getter = getter.overloadGetter(); - expect(getter('aa')).toEqual(1); - expect(getter('bb')).toEqual(2); - expect(getter('cc')).toEqual(3); - expect(getter('dd')).toBeNull(); + expect(getter('aa')).to.equal(1); + expect(getter('bb')).to.equal(2); + expect(getter('cc')).to.equal(3); + expect(getter('dd')).to.equal(null); - expect(getter('aa', 'bb', 'cc')).toEqual(object); - expect(getter(['aa', 'bb', 'cc'])).toEqual(object); - expect(getter(['aa', 'cc', 'dd'])).toEqual({aa: 1, cc: 3, dd: null}); + expect(getter('aa', 'bb', 'cc')).to.deep.equal(object); + expect(getter(['aa', 'bb', 'cc'])).to.deep.equal(object); + expect(getter(['aa', 'cc', 'dd'])).to.deep.equal({aa: 1, cc: 3, dd: null}); }); it('should work in plural mode', function(){ getter = getter.overloadGetter(true); - expect(getter('aa')).toEqual({ + expect(getter('aa')).to.deep.equal({ aa: 1 }); - expect(getter(['aa', 'bb'])).toEqual({ + expect(getter(['aa', 'bb'])).to.deep.equal({ aa: 1, bb: 2 }); @@ -524,51 +527,51 @@ describe('Function.prototype.overloadGetter', function(){ describe('typeOf', function(){ it("should return 'array' for Array objects", function(){ - expect(typeOf([1,2])).toEqual('array'); + expect(typeOf([1,2])).to.equal('array'); }); it("should return 'string' for String objects", function(){ - expect(typeOf('ciao')).toEqual('string'); + expect(typeOf('ciao')).to.equal('string'); }); it("should return 'regexp' for RegExp objects", function(){ - expect(typeOf(/_/)).toEqual('regexp'); + expect(typeOf(/_/)).to.equal('regexp'); }); it("should return 'function' for Function objects", function(){ - expect(typeOf(function(){})).toEqual('function'); + expect(typeOf(function(){})).to.equal('function'); }); it("should return 'number' for Number objects", function(){ - expect(typeOf(10)).toEqual('number'); - expect(typeOf(NaN)).not.toEqual('number'); + expect(typeOf(10)).to.equal('number'); + expect(typeOf(NaN)).to.not.equal('number'); }); it("should return 'boolean' for Boolean objects", function(){ - expect(typeOf(true)).toEqual('boolean'); - expect(typeOf(false)).toEqual('boolean'); + expect(typeOf(true)).to.equal('boolean'); + expect(typeOf(false)).to.equal('boolean'); }); it("should return 'object' for Object objects", function(){ - expect(typeOf({a:2})).toEqual('object'); + expect(typeOf({a:2})).to.equal('object'); }); it("should return 'arguments' for Function arguments", function(){ if (typeof window != 'undefined' && window.opera){ // Seems like the Opera guys can't decide on this var type = typeOf(arguments); - expect(type == 'array' || type == 'arguments').toBeTruthy(); + expect(type == 'array' || type == 'arguments').to.equal(true); return; } - expect(typeOf(arguments)).toEqual('arguments'); + expect(typeOf(arguments)).to.equal('arguments'); }); it("should return 'null' for null objects", function(){ - expect(typeOf(null)).toEqual('null'); + expect(typeOf(null)).to.equal('null'); }); it("should return 'null' for undefined objects", function(){ - expect(typeOf(undefined)).toEqual('null'); + expect(typeOf(undefined)).to.equal('null'); }); }); @@ -576,43 +579,43 @@ describe('typeOf', function(){ describe('instanceOf', function(){ it("should return false on null object", function(){ - expect(instanceOf(null, null)).toBeFalsy(); + expect(instanceOf(null, null)).to.equal(false); }); it("should return true for Arrays", function(){ - expect(instanceOf([], Array)).toBeTruthy(); + expect(instanceOf([], Array)).to.equal(true); }); it("should return true for Numbers", function(){ - expect(instanceOf(1, Number)).toBeTruthy(); + expect(instanceOf(1, Number)).to.equal(true); }); it("should return true for Objects", function(){ - expect(instanceOf({}, Object)).toBeTruthy(); + expect(instanceOf({}, Object)).to.equal(true); }); it("should return true for Dates", function(){ - expect(instanceOf(new Date(), Date)).toBeTruthy(); + expect(instanceOf(new Date(), Date)).to.equal(true); }); it("should return true for Booleans", function(){ - expect(instanceOf(true, Boolean)).toBeTruthy(); + expect(instanceOf(true, Boolean)).to.equal(true); }); it("should return true for RegExps", function(){ - expect(instanceOf(/_/, RegExp)).toBeTruthy(); + expect(instanceOf(/_/, RegExp)).to.equal(true); }); it("should respect the parent property of a custom object", function(){ var X = function(){}; X.parent = Array; - expect(instanceOf(new X, Array)).toBeTruthy(); + expect(instanceOf(new X, Array)).to.equal(true); }); // todo(ibolmo) var dit = typeof window != 'undefined' && window.Element && Element.set ? it : xit; dit("should return true for Element instances", function(){ - expect(instanceOf(new Element('div'), Element)).toBeTruthy(); + expect(instanceOf(new Element('div'), Element)).to.equal(true); }); }); @@ -622,7 +625,7 @@ describe('Array.from', function(){ it('should return the same array', function(){ var arr1 = [1,2,3]; var arr2 = Array.from(arr1); - expect(arr1 === arr2).toBeTruthy(); + expect(arr1).to.equal(arr2); }); it('should return an array for arguments', function(){ @@ -630,21 +633,21 @@ describe('Array.from', function(){ return Array.from(arguments); }; var arr = fnTest(1,2,3); - expect(Type.isArray(arr)).toBeTruthy(); - expect(arr.length).toEqual(3); + expect(Type.isArray(arr)).to.equal(true); + expect(arr.length).to.equal(3); }); it('should transform a non array into an array', function(){ - expect(Array.from(1)).toEqual([1]); + expect(Array.from(1)).to.deep.equal([1]); }); it('should transforum an undefined or null into an empty array', function(){ - expect(Array.from(null)).toEqual([]); - expect(Array.from(undefined)).toEqual([]); + expect(Array.from(null)).to.deep.equal([]); + expect(Array.from(undefined)).to.deep.equal([]); }); it('should ignore and return an array', function(){ - expect(Array.from([1,2,3])).toEqual([1,2,3]); + expect(Array.from([1,2,3])).to.deep.equal([1,2,3]); }); it('should return a copy of arguments or the arguments if it is of type array', function(){ @@ -658,7 +661,11 @@ describe('Array.from', function(){ return Array.from(arguments); })(1, 2); - expect((type == 'array') ? (copy === args) : (copy !== args)).toBeTruthy(); + if (type === 'array'){ + expect(copy).to.equal(args); + } else { + expect(copy).to.not.equal(args); + } }); }); @@ -666,13 +673,13 @@ describe('Array.from', function(){ describe('String.from', function(){ it('should convert to type string', function(){ - expect(typeOf(String.from('string'))).toBe('string'); + expect(typeOf(String.from('string'))).to.equal('string'); - expect(typeOf(String.from(1))).toBe('string'); + expect(typeOf(String.from(1))).to.equal('string'); - expect(typeOf(String.from(new Date))).toBe('string'); + expect(typeOf(String.from(new Date))).to.equal('string'); - expect(typeOf(String.from(function(){}))).toBe('string'); + expect(typeOf(String.from(function(){}))).to.equal('string'); }); }); @@ -681,11 +688,11 @@ describe('Function.from', function(){ it('if a function is passed in that function should be returned', function(){ var fn = function(a,b){ return a; }; - expect(Function.from(fn)).toEqual(fn); + expect(Function.from(fn)).to.equal(fn); }); it('should return a function that returns the value passed when called', function(){ - expect(Function.from('hello world!')()).toEqual('hello world!'); + expect(Function.from('hello world!')()).to.equal('hello world!'); }); }); @@ -693,12 +700,12 @@ describe('Function.from', function(){ describe('Number.from', function(){ it('should return the number representation of a string', function(){ - expect(Number.from("10")).toEqual(10); - expect(Number.from("10px")).toEqual(10); + expect(Number.from("10")).to.equal(10); + expect(Number.from("10px")).to.equal(10); }); it('should return null when it fails to return a number type', function(){ - expect(Number.from("ciao")).toBeNull(); + expect(Number.from("ciao")).to.equal(null); }); }); @@ -732,7 +739,7 @@ describe('Type', function(){ } }); var myInstrument = new Instrument('Guitar'); - expect(myInstrument.method()).toEqual('playing a guitar'); + expect(myInstrument.method()).to.equal('playing a guitar'); }); it('should not override a method when it is protected', function(){ @@ -742,28 +749,28 @@ describe('Type', function(){ } }); var myCar = new Car('nice car'); - expect(myCar.method()).toEqual('driving a nice car'); + expect(myCar.method()).to.equal('driving a nice car'); }); it('should allow generic calls', function(){ - expect(Car.method({name: 'not so nice car'})).toEqual('driving a not so nice car'); + expect(Car.method({name: 'not so nice car'})).to.equal('driving a not so nice car'); }); it("should be a Type", function(){ - expect(Type.isType(Instrument)).toBeTruthy(); + expect(Type.isType(Instrument)).to.equal(true); }); it("should generate and evaluate correct types", function(){ var myCar = new Car('nice car'); - expect(Type.isCar(myCar)).toBeTruthy(); + expect(Type.isCar(myCar)).to.equal(true); }); it("isEnumerable method on Type should return true for arrays, arguments, objects with a numerical length property", function(){ - expect(Type.isEnumerable([1,2,3])).toBeTruthy(); + expect(Type.isEnumerable([1,2,3])).to.equal(true); (function(){ - expect(Type.isEnumerable(arguments)).toBeTruthy(); + expect(Type.isEnumerable(arguments)).to.equal(true); })(1,2,3); - expect(Type.isEnumerable({length: 2})).toBeTruthy(); + expect(Type.isEnumerable({length: 2})).to.equal(true); }); it('sould chain any function on a type', function(){ @@ -775,7 +782,7 @@ describe('Type', function(){ method: function(){} }).extend({ staticMethod: function(){} - })).toBe(MyType); + })).to.equal(MyType); }); }); @@ -785,18 +792,18 @@ describe('Object.keys', function(){ var object = { a: 'string', b: 233, c: {} }; it('keys should return an empty array', function(){ - expect(Object.keys({})).toEqual([]); + expect(Object.keys({})).to.deep.equal([]); }); it('should return an array containing the keys of the object', function(){ - expect(Object.keys(object)).toEqual(['a', 'b', 'c']); + expect(Object.keys(object)).to.deep.equal(['a', 'b', 'c']); }); it('should return an array containing non-enum keys', function(){ var buggy = {constructor: 'foo', valueOf: 'bar'}; var keys = Object.keys(buggy).join(''); - expect(keys.indexOf('constructor') != -1).toBeTruthy(); - expect(keys.indexOf('valueOf') != -1).toBeTruthy(); + expect(keys.indexOf('constructor')).to.not.equal(-1); + expect(keys.indexOf('valueOf')).to.not.equal(-1); }); }); @@ -809,7 +816,7 @@ describe('Object.each', function(){ daysObj[key] = value; }); - expect(daysObj).toEqual({first: 'Sunday', second: 'Monday', third: 'Tuesday'}); + expect(daysObj).to.deep.equal({first: 'Sunday', second: 'Monday', third: 'Tuesday'}); }); it('should call non-enumerable properties too', function(){ @@ -832,8 +839,8 @@ describe('Object.each', function(){ if (props.indexOf(k) == -1) keysInObject = false; }); - expect(keysInObject).toBeTruthy(); - expect(iteration).toEqual(8); + expect(keysInObject).to.equal(true); + expect(iteration).to.equal(8); }); }); @@ -848,7 +855,7 @@ describe('Array.each', function(){ }); })('Sun','Mon','Tue'); - expect(daysArr).toEqual(['Sun','Mon','Tue']); + expect(daysArr).to.deep.equal(['Sun','Mon','Tue']); }); it('should call the function for each item in the array', function(){ @@ -857,7 +864,7 @@ describe('Array.each', function(){ daysArr.push(value); }); - expect(daysArr).toEqual(['Sun','Mon','Tue']); + expect(daysArr).to.deep.equal(['Sun','Mon','Tue']); }); it('should not iterate over deleted elements', function(){ @@ -870,7 +877,7 @@ describe('Array.each', function(){ testArray.push(value); }); - expect(testArray).toEqual([0, 3]); + expect(testArray).to.deep.equal([0, 3]); }); }); @@ -879,14 +886,14 @@ describe('Array.clone', function(){ it('should recursively clone and dereference arrays and objects, while mantaining the primitive values', function(){ var a = [1,2,3, [1,2,3, {a: [1,2,3]}]]; var b = Array.clone(a); - expect(a === b).toBeFalsy(); - expect(a[3] === b[3]).toBeFalsy(); - expect(a[3][3] === b[3][3]).toBeFalsy(); - expect(a[3][3].a === b[3][3].a).toBeFalsy(); + expect(a).to.not.equal(b); + expect(a[3]).to.not.equal(b[3]); + expect(a[3][3]).to.not.equal(b[3][3]); + expect(a[3][3].a).to.not.equal(b[3][3].a); - expect(a[3]).toEqual(b[3]); - expect(a[3][3]).toEqual(b[3][3]); - expect(a[3][3].a).toEqual(b[3][3].a); + expect(a[3]).to.deep.equal(b[3]); + expect(a[3][3]).to.deep.equal(b[3][3]); + expect(a[3][3].a).to.deep.equal(b[3][3].a); }); }); @@ -894,14 +901,14 @@ describe('Object.clone', function(){ it('should recursively clone and dereference arrays and objects, while mantaining the primitive values', function(){ var a = {a:[1,2,3, [1,2,3, {a: [1,2,3]}]]}; var b = Object.clone(a); - expect(a === b).toBeFalsy(); - expect(a.a[3] === b.a[3]).toBeFalsy(); - expect(a.a[3][3] === b.a[3][3]).toBeFalsy(); - expect(a.a[3][3].a === b.a[3][3].a).toBeFalsy(); + expect(a).to.not.equal(b); + expect(a.a[3]).to.not.equal(b.a[3]); + expect(a.a[3][3]).to.not.equal(b.a[3][3]); + expect(a.a[3][3].a).to.not.equal(b.a[3][3].a); - expect(a.a[3]).toEqual(b.a[3]); - expect(a.a[3][3]).toEqual(b.a[3][3]); - expect(a.a[3][3].a).toEqual(b.a[3][3].a); + expect(a.a[3]).to.deep.equal(b.a[3]); + expect(a.a[3][3]).to.deep.equal(b.a[3][3]); + expect(a.a[3][3].a).to.deep.equal(b.a[3][3].a); }); }); @@ -914,10 +921,10 @@ describe('Object.merge', function(){ var merger = Object.merge(a, b); - expect(merger).toEqual({a:1, b:2, c:{a:1, b:2, c:3, d:4}, d:4}); - expect(merger === a).toBeTruthy(); + expect(merger).to.deep.equal({a:1, b:2, c:{a:1, b:2, c:3, d:4}, d:4}); + expect(merger).to.equal(a); - expect(Object.merge(a, b, c)).toEqual({a:5, b:2, c:{a:5, b:2, c:3, d:4}, d:4}); + expect(Object.merge(a, b, c)).to.deep.equal({a:5, b:2, c:{a:5, b:2, c:3, d:4}, d:4}); }); it('should recursively clone sub objects and sub-arrays', function(){ @@ -926,8 +933,8 @@ describe('Object.merge', function(){ var merger = Object.merge(a, b); - expect(a.e === b.e).toBeFalsy(); - expect(a.f === b.f).toBeFalsy(); + expect(a.e).to.not.equal(b.e); + expect(a.f).to.not.equal(b.f); }); }); @@ -935,21 +942,21 @@ describe('Object.merge', function(){ describe('Object.append', function(){ it('should combine two objects', function(){ var a = {a: 1, b: 2}, b = {b: 3, c: 4}; - expect(Object.append(a, b)).toEqual({a: 1, b: 3, c: 4}); + expect(Object.append(a, b)).to.deep.equal({a: 1, b: 3, c: 4}); a = {a: 1, b: 2}; b = {b: 3, c: 4}; - expect(Object.append(a, b)).toEqual(a); + expect(Object.append(a, b)).to.equal(a); a = {a: 1, b: 2}; b = {b: 3, c: 4}; var c = {a: 2, d: 5}; - expect(Object.append(a, b, c)).toEqual({a: 2, b: 3, c: 4, d: 5}); + expect(Object.append(a, b, c)).to.deep.equal({a: 2, b: 3, c: 4, d: 5}); }); }); describe('Date.now', function(){ it('should return a timestamp', function(){ - expect(Type.isNumber(Date.now())).toBeTruthy(); + expect(Type.isNumber(Date.now())).to.equal(true); }); }); @@ -957,11 +964,11 @@ describe('Date.now', function(){ describe('String.uniqueID', function(){ it('should be a string', function(){ - expect(typeof String.uniqueID()).toBe('string'); + expect(typeof String.uniqueID()).to.equal('string'); }); it("should generate unique ids", function(){ - expect(String.uniqueID()).not.toEqual(String.uniqueID()); + expect(String.uniqueID()).to.not.equal(String.uniqueID()); }); }); @@ -970,25 +977,25 @@ describe('typeOf Client', function(){ var dit = typeof document == 'undefined' ? xit : it; dit("should return 'collection' for HTMLElements collections", function(){ - expect(typeOf(document.getElementsByTagName('*'))).toEqual('collection'); + expect(typeOf(document.getElementsByTagName('*'))).to.equal('collection'); }); dit("should return 'element' for an Element", function(){ var div = document.createElement('div'); - expect(typeOf(div)).toEqual('element'); + expect(typeOf(div)).to.equal('element'); }); // todo(ibolmo) if (typeof window != 'undefined' && window.Elements) dit("should return 'elements' for Elements", function(){ - expect(typeOf(new Elements)).toEqual('elements'); + expect(typeOf(new Elements)).to.equal('elements'); }); if (typeof window != 'undefined' && window.Browser) dit("should return 'window' for the window object", function(){ - expect(typeOf(window)).toEqual('window'); + expect(typeOf(window)).to.equal('window'); }); if (typeof window != 'undefined' && window.Browser) dit("should return 'document' for the document object", function(){ - expect(typeOf(document)).toEqual('document'); + expect(typeOf(document)).to.equal('document'); }); }); @@ -1005,7 +1012,7 @@ describe('Array.from', function(){ div1.appendChild(div3); var array = Array.from(div1.getElementsByTagName('*')); - expect(Type.isArray(array)).toEqual(true); + expect(Type.isArray(array)).to.equal(true); }); dit('should return an array for an Options collection', function(){ @@ -1013,7 +1020,7 @@ describe('Array.from', function(){ div.innerHTML = ''; var select = div.firstChild; var array = Array.from(select.options); - expect(Type.isArray(array)).toEqual(true); + expect(Type.isArray(array)).to.equal(true); }); }); @@ -1024,7 +1031,7 @@ describe('Core', function(){ describe('typeOf', function(){ it('should correctly report the type of arguments when using "use strict"', function(){ "use strict"; - expect(typeOf(arguments)).toEqual('arguments'); + expect(typeOf(arguments)).to.equal('arguments'); }); }); diff --git a/Specs/Core/Native.js b/Specs/Core/Native.js index bcb94933..33b1bdc0 100644 --- a/Specs/Core/Native.js +++ b/Specs/Core/Native.js @@ -54,15 +54,15 @@ describe('Native (private)', function(){ it('should allow implementation over existing methods when browser option is not set', function(){ Instrument.implement({ property: 'staff' }); var myInstrument = new Instrument('xeelophone'); - expect(myInstrument.method()).toEqual('staff xeelophone'); + expect(myInstrument.method()).to.equal('staff xeelophone'); }); it('should allow generic calls', function(){ - expect(Car.method({name: 'ciccio', property: 'bello'})).toEqual('ciccio_bello'); + expect(Car.method({name: 'ciccio', property: 'bello'})).to.equal('ciccio_bello'); }); it("should have a 'native' type", function(){ - expect(Native.type(Car)).toBeTruthy(); + expect(Native.type(Car)).to.equal(true); }); }); diff --git a/Specs/Core/Type.js b/Specs/Core/Type.js index 4b7c8de9..c1278fb1 100644 --- a/Specs/Core/Type.js +++ b/Specs/Core/Type.js @@ -41,15 +41,15 @@ describe('Type (private)', function(){ it('should allow implementation over existing methods when browser option is not set', function(){ Instrument.implement({ property: 'staff' }); var myInstrument = new Instrument('xeelophone'); - expect(myInstrument.method()).toEqual('staff xeelophone'); + expect(myInstrument.method()).to.equal('staff xeelophone'); }); it('should allow generic calls', function(){ - expect(Car.method({name: 'ciccio', property: 'bello'})).toEqual('ciccio_bello'); + expect(Car.method({name: 'ciccio', property: 'bello'})).to.equal('ciccio_bello'); }); it("should have a 'native' type", function(){ - expect(Type.isType(Car)).toBeTruthy(); + expect(Type.isType(Car)).to.equal(true); }); }); diff --git a/Specs/Element/Element.Delegation.js b/Specs/Element/Element.Delegation.js index ab6accf6..bd8300fa 100644 --- a/Specs/Element/Element.Delegation.js +++ b/Specs/Element/Element.Delegation.js @@ -18,8 +18,8 @@ describe('Element.Delegation', function(){ self = this; }).fireEvent('click:relay(a)', [null, a]); - expect(result).toEqual(a); - expect(self).toEqual(div); + expect(result).to.equal(a); + expect(self).to.equal(div); div.destroy(); @@ -33,8 +33,8 @@ describe('Element.Delegation', function(){ self = this; }).fireEvent('click', [null, a]); - expect(result).toEqual(a); - expect(self).toEqual(a); + expect(result).to.equal(a); + expect(self).to.equal(a); div.destroy(); @@ -46,7 +46,7 @@ describe('Element.Delegation', function(){ var a = new Element('a[text="Hello World"]'); var div = new Element('div').inject(document.body).adopt(a).addEvent('click:relay(a)', spy).fireEvent('click'); - expect(spy.called).toBe(false); + expect(spy.called).to.equal(false); div.destroy(); diff --git a/Specs/Element/Element.Dimensions.js b/Specs/Element/Element.Dimensions.js index 46412afd..f5e1f506 100755 --- a/Specs/Element/Element.Dimensions.js +++ b/Specs/Element/Element.Dimensions.js @@ -83,8 +83,8 @@ describe('Element.Dimensions', function(){ describe('Element.getSize', function(){ it('should measure the width and height of the element', function(){ - expect(div.getSize().x).toEqual(108); - expect(div.getSize().y).toEqual(108); + expect(div.getSize().x).to.equal(108); + expect(div.getSize().y).to.equal(108); }); }); @@ -177,8 +177,8 @@ describe('Element.Dimensions', function(){ var svgElement = document.getElement('svg'); it("should get the correct height and width of a svg element", function(){ - expect(svgElement.getSize().y).toEqual(200); - expect(svgElement.getSize().x).toEqual(142); + expect(svgElement.getSize().y).to.equal(200); + expect(svgElement.getSize().x).to.equal(142); svgElement.destroy(); }); }); @@ -186,11 +186,11 @@ describe('Element.Dimensions', function(){ describe('Element.getPosition', function(){ it('should measure the x and y position of the element', function(){ - expect(div.getPosition()).toEqual({x: 102, y: 102}); + expect(div.getPosition()).to.deep.equal({x: 102, y: 102}); }); it('should measure the x and y position of the element relative to another', function(){ - expect(relDiv.getPosition(div)).toEqual({x: 8, y: 8}); + expect(relDiv.getPosition(div)).to.deep.equal({x: 8, y: 8}); }); it('should match subpixels if needed', function(){ @@ -217,7 +217,7 @@ describe('Element.Dimensions', function(){ }).inject(oddSizedDiv); expect(insideOddSizedDiv.getPosition(oddSizedDiv).x) - .toEqual(insideOddSizedDiv.getBoundingClientRect().left - oddSizedDiv.getBoundingClientRect().left); + .to.equal(insideOddSizedDiv.getBoundingClientRect().left - oddSizedDiv.getBoundingClientRect().left); }); }); @@ -225,7 +225,7 @@ describe('Element.Dimensions', function(){ describe('Element.getCoordinates', function(){ it('should return the coordinates relative to parent', function(){ - expect(absDiv.getCoordinates(relDiv)).toEqual({left:15, top:15, width:22, height:22, right:37, bottom:37}); + expect(absDiv.getCoordinates(relDiv)).to.deep.equal({left:15, top:15, width:22, height:22, right:37, bottom:37}); }); }); @@ -233,7 +233,7 @@ describe('Element.Dimensions', function(){ describe('Element.getScrollSize', function(){ it('should return the scrollSize', function(){ - expect(scrollDiv.getScrollSize()).toEqual({x:200, y:200}); + expect(scrollDiv.getScrollSize()).to.deep.equal({x:200, y:200}); }); }); @@ -241,7 +241,7 @@ describe('Element.Dimensions', function(){ describe('Element.scrollTo', function(){ it('should scroll the element', function(){ - expect(scrollDiv.scrollTo(20, 20).getScroll()).toEqual({x:20, y:20}); + expect(scrollDiv.scrollTo(20, 20).getScroll()).to.deep.equal({x:20, y:20}); }); }); @@ -281,19 +281,19 @@ describe('Element.getOffsetParent', function(){ it('Should return the right offsetParent', function(){ - expect(child.getOffsetParent()).toEqual(offsetParent); + expect(child.getOffsetParent()).to.equal(offsetParent); }); it('Should return body for elements with body as offsetParent', function(){ - expect(offsetParent.getOffsetParent()).toEqual(document.body); + expect(offsetParent.getOffsetParent()).to.equal(document.body); }); it('Should return a table element for td-elements', function(){ - expect(td.getOffsetParent()).toEqual(table); + expect(td.getOffsetParent()).to.equal(table); }); @@ -301,7 +301,7 @@ describe('Element.getOffsetParent', function(){ child.inject(td); - expect(child.getOffsetParent()).toEqual(td); + expect(child.getOffsetParent()).to.equal(td); }); @@ -309,7 +309,7 @@ describe('Element.getOffsetParent', function(){ child.setStyle('position', 'absolute'); - expect(child.getOffsetParent()).toEqual(offsetParent); + expect(child.getOffsetParent()).to.equal(offsetParent); }); @@ -317,13 +317,13 @@ describe('Element.getOffsetParent', function(){ table.setStyle('position', 'fixed'); - expect(table.getOffsetParent()).toBeNull(); + expect(table.getOffsetParent()).to.equal(null); }); it('Should return null for the body element', function(){ - expect($(document.body).getOffsetParent()).toBeNull(); + expect($(document.body).getOffsetParent()).to.equal(null); }); diff --git a/Specs/Element/Element.Event.js b/Specs/Element/Element.Event.js index 2e938b33..aca7d0e2 100644 --- a/Specs/Element/Element.Event.js +++ b/Specs/Element/Element.Event.js @@ -28,7 +28,7 @@ describe('Events API: Element', function(){ object.addEvent('event', Local.fn)[fire]('event'); - expect(Local.called).toEqual(1); + expect(Local.called).to.equal(1); }); it('should add multiple Events to the Class', function(){ @@ -37,7 +37,7 @@ describe('Events API: Element', function(){ event2: Local.fn })[fire]('event1')[fire]('event2'); - expect(Local.called).toEqual(2); + expect(Local.called).to.equal(2); }); it('should remove a specific method for an event', function(){ @@ -46,8 +46,8 @@ describe('Events API: Element', function(){ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvent('event', Local.fn)[fire]('event'); - expect(x).toEqual(1); - expect(Local.called).toEqual(0); + expect(x).to.equal(1); + expect(Local.called).to.equal(0); }); it('should remove an event and its methods', function(){ @@ -56,8 +56,8 @@ describe('Events API: Element', function(){ object.addEvent('event', Local.fn).addEvent('event', fn).removeEvents('event')[fire]('event'); - expect(x).toEqual(0); - expect(Local.called).toEqual(0); + expect(x).to.equal(0); + expect(Local.called).to.equal(0); }); it('should remove all events', function(){ @@ -70,8 +70,8 @@ describe('Events API: Element', function(){ // Should not fail object.removeEvents()[fire]('event1')[fire]('event2'); - expect(x).toEqual(0); - expect(Local.called).toEqual(0); + expect(x).to.equal(0); + expect(Local.called).to.equal(0); }); it('should remove events with an object', function(){ @@ -82,14 +82,14 @@ describe('Events API: Element', function(){ }; object.addEvent('event1', function(){ Local.fn(); }).addEvents(events)[fire]('event1'); - expect(Local.called).toEqual(2); + expect(Local.called).to.equal(2); object.removeEvents(events); object[fire]('event1'); - expect(Local.called).toEqual(3); + expect(Local.called).to.equal(3); object[fire]('event2'); - expect(Local.called).toEqual(3); + expect(Local.called).to.equal(3); }); it('should remove an event immediately', function(){ @@ -109,10 +109,10 @@ describe('Events API: Element', function(){ }).addEvent('event', three); object[fire]('event'); - expect(methods).toEqual([1, 2]); + expect(methods).to.deep.equal([1, 2]); object[fire]('event'); - expect(methods).toEqual([1, 2, 1, 2]); + expect(methods).to.deep.equal([1, 2, 1, 2]); }); it('should be able to remove itself', function(){ @@ -135,10 +135,10 @@ describe('Events API: Element', function(){ object.addEvent('event', one).addEvent('event', two).addEvent('event', three); object[fire]('event'); - expect(methods).toEqual([1, 2, 3]); + expect(methods).to.deep.equal([1, 2, 3]); object[fire]('event'); - expect(methods).toEqual([1, 2, 3, 3]); + expect(methods).to.deep.equal([1, 2, 3, 3]); }); }); @@ -172,7 +172,7 @@ describe('Element.Event', function(){ syn.trigger(el, 'click'); - expect(callback.called).toBe(true); + expect(callback.called).to.equal(true); el.destroy(); }); @@ -197,7 +197,7 @@ describe('Element.Event', function(){ syn.trigger(el, 'click'); - expect(callback.called).toBe(true); + expect(callback.called).to.equal(true); el.destroy(); }); @@ -218,8 +218,8 @@ describe('Element.Event', function(){ }); it('Should trigger a message event', function(){ - expect(this.spy.called).toBe(true); - expect(this.message).toEqual('I am a message from outer space...'); + expect(this.spy.called).to.equal(true); + expect(this.message).to.equal('I am a message from outer space...'); }); }); @@ -233,7 +233,7 @@ describe('Element.Event', function(){ syn.key(div, 'a'); - expect(callback.calledWith('a')).toBe(true); + expect(callback.calledWith('a')).to.equal(true); div.destroy(); }); @@ -244,25 +244,25 @@ describe('Element.Event', function(){ var element = new Element('div').addEvent('click', function(){ calls++; }); element.fireEvent('click'); - expect(calls).toBe(1); + expect(calls).to.equal(1); var clone = new Element('div').cloneEvents(element, 'click'); clone.fireEvent('click'); - expect(calls).toBe(2); + expect(calls).to.equal(2); element.addEvent('custom', function(){ calls += 2; }).fireEvent('custom'); - expect(calls).toBe(4); + expect(calls).to.equal(4); clone.cloneEvents(element); clone.fireEvent('click'); - expect(calls).toBe(5); + expect(calls).to.equal(5); clone.fireEvent('custom'); - expect(calls).toBe(7); + expect(calls).to.equal(7); }); }); @@ -275,7 +275,7 @@ describe('Element.Event', function(){ var callback = sinon.spy(); var fn = function(anything, type){ - expect(type).toEqual('customEvent'); + expect(type).to.equal('customEvent'); callbacks++; }; Element.Events.customEvent = { @@ -296,9 +296,9 @@ describe('Element.Event', function(){ syn.trigger(div, 'click'); - expect(callback.called).toBe(true); + expect(callback.called).to.equal(true); div.removeEvent('customEvent', callback).destroy(); - expect(callbacks).toEqual(3); + expect(callbacks).to.equal(3); }); }); @@ -315,7 +315,7 @@ describe('Element.Event.change', function(){ }).addEvent('change', callback).inject(document.body); radio.removeClass('someClass'); - expect(callback.called).toBe(false); + expect(callback.called).to.equal(false); var checkbox = new Element('input', { 'type': 'checkbox', @@ -324,7 +324,7 @@ describe('Element.Event.change', function(){ }).addEvent('change', callback).inject(document.body); checkbox.removeClass('someClass'); - expect(callback.called).toBe(false); + expect(callback.called).to.equal(false); var text = new Element('input', { 'type': 'text', @@ -333,7 +333,7 @@ describe('Element.Event.change', function(){ }).addEvent('change', callback).inject(document.body); text.removeClass('otherClass'); - expect(callback.called).toBe(false); + expect(callback.called).to.equal(false); [radio, checkbox, text].invoke('destroy'); }); @@ -359,8 +359,8 @@ describe('Element.Event keyup with f', function(){ syn.trigger(div, 'keydown', 'f2'); syn.trigger(div, 'keyup', 'f2'); - expect(keydown.calledWith('f2')).toBe(true); - expect(keyup.calledWith('f2')).toBe(true); + expect(keydown.calledWith('f2')).to.equal(true); + expect(keyup.calledWith('f2')).to.equal(true); div.destroy(); @@ -413,24 +413,24 @@ describe('Keypress key code', function(){ }); it('should return "enter" in event.key', function(){ - expect(key).toBe('enter'); - expect(shift).not.toBeTruthy(); + expect(key).to.equal('enter'); + expect(shift).to.equal(false); }); it('should return "1" in event.key', function(){ - expect(key).toBe('1'); - expect(shift).not.toBeTruthy(); + expect(key).to.equal('1'); + expect(shift).to.equal(false); }); it('should return "!" when pressing SHIFT + 1', function(){ - expect(key).toBe('!'); - expect(shift).toBeTruthy(); + expect(key).to.equal('!'); + expect(shift).to.equal(true); }); it('should map code 33 correctly with keypress event', function(){ var mock = {type: 'keypress', which: 33, shiftKey: true}; var e = new DOMEvent(mock); - expect(e.key).toBe('!'); + expect(e.key).to.equal('!'); }); }); @@ -443,7 +443,7 @@ describe('Element.removeEvent', function(){ window.addEvent('unload', handler); window.removeEvent('unload', handler); window.fireEvent('unload'); - expect(text).toBe(undefined); + expect(text).to.equal(undefined); }); @@ -459,8 +459,8 @@ describe('relatedTarget', function () { mockEvent[(i % 2 == 0 ? 'from' : 'to') + 'Element'] = outer; // simulate FF that does not set relatedTarget var e = new DOMEvent(mockEvent); - expect(e.type).toBe(event); - expect(e.relatedTarget).toBe(outer); + expect(e.type).to.equal(event); + expect(e.relatedTarget).to.equal(outer); }); }); @@ -521,7 +521,7 @@ describe('Mouse wheel', function(){ var testWheel = !!window.addEventListener; var callback = function(e){ if (e.wheel) wheel = e.wheel > 0 ? 'wheel moved up' : 'wheel moved down'; - triggered = 'triggered'; + triggered = true; }; beforeEach(function(){ @@ -539,7 +539,7 @@ describe('Mouse wheel', function(){ // http://jsfiddle.net/W6QrS/3 ['mousewheel', 'wheel' ,'DOMMouseScroll' ].each(dispatchFakeWheel); - expect(triggered).toBeTruthy(); + expect(triggered).to.equal(true); }); it('should listen to mouse wheel direction', function(){ @@ -551,14 +551,14 @@ describe('Mouse wheel', function(){ ['mousewheel', 'wheel' ,'DOMMouseScroll' ].each(function(type){ dispatchFakeWheel(type, 120); }); - expect(wheel).toEqual('wheel moved up'); + expect(wheel).to.equal('wheel moved up'); wheel = false; // fire event with wheel going down ['mousewheel', 'wheel' ,'DOMMouseScroll' ].each(function(type){ dispatchFakeWheel(type, -120); }); - expect(wheel).toEqual('wheel moved down'); + expect(wheel).to.equal('wheel moved down'); }); }); diff --git a/Specs/Element/Element.Style.js b/Specs/Element/Element.Style.js index 44521c95..a0b17742 100644 --- a/Specs/Element/Element.Style.js +++ b/Specs/Element/Element.Style.js @@ -12,18 +12,18 @@ describe('Element.set `opacity`', function(){ it('should set the opacity of an Element', function(){ var el = new Element('div').set('opacity', 0.4); if (document.html.style.opacity != null) - expect(el.style.opacity).toEqual('0.4'); + expect(el.style.opacity).to.equal('0.4'); else if (document.html.style.filter != null) - expect(el.style.filter).toEqual('alpha(opacity=40)'); + expect(el.style.filter).to.equal('alpha(opacity=40)'); else - expect(el.getStyle('opacity')).toEqual(0.4); + expect(el.getStyle('opacity')).to.equal(0.4); }); it('should return the opacity of an Element', function(){ var div = new Element('div').set('opacity', 0.4); - expect(div.get('opacity') == 0.4).toBeTruthy(); + expect(div.get('opacity')).to.equal(0.4); div.set('opacity', 0); - expect(div.get('opacity') == 0).toBeTruthy(); + expect(div.get('opacity')).to.equal(0); }); }); @@ -34,18 +34,18 @@ describe('Element.set `opacity`', function(){ it('should set the opacity of an Element', function(){ var el = new Element('div').setStyle('opacity', 0.4); if (document.html.style.opacity != null) - expect(el.style.opacity).toEqual('0.4'); + expect(el.style.opacity).to.equal('0.4'); else if (document.html.style.filter != null) - expect(el.style.filter).toEqual('alpha(opacity=40)'); + expect(el.style.filter).to.equal('alpha(opacity=40)'); else - expect(el.getStyle('opacity')).toEqual(0.4); + expect(el.getStyle('opacity')).to.equal(0.4); }); it('should return the opacity of an Element', function(){ var div = new Element('div').setStyle('opacity', 0.4); - expect(div.getStyle('opacity') == 0.4).toBeTruthy(); + expect(div.getStyle('opacity')).to.equal(0.4); div.setStyle('opacity', 0); - expect(div.getStyle('opacity') == 0).toBeTruthy(); + expect(div.getStyle('opacity')).to.equal(0); }); }); @@ -54,22 +54,22 @@ describe('Element.getStyle', function(){ it('should get a six digit hex code from a three digit hex code', function(){ var el = new Element('div').set('html', '
'); - expect(el.getElement('div').getStyle('color')).toEqual('#00ff00'); + expect(el.getElement('div').getStyle('color')).to.equal('#00ff00'); }); it('should getStyle a six digit hex code from an RGB value', function(){ var el = new Element('div').set('html', '
'); - expect(el.getElement('div').getStyle('color')).toEqual('#00ff00'); + expect(el.getElement('div').getStyle('color')).to.equal('#00ff00'); }); it('should `getStyle` with a dash in it', function(){ var el = new Element('div').set('html', '
'); - expect(el.getElement('div').getStyle('list-style-type')).toEqual('square'); + expect(el.getElement('div').getStyle('list-style-type')).to.equal('square'); }); it('should `getStyle` padding', function(){ var el = new Element('div').set('html', '
'); - expect(el.getElement('div').getStyle('padding-left')).toEqual('20px'); + expect(el.getElement('div').getStyle('padding-left')).to.equal('20px'); }); }); @@ -77,15 +77,15 @@ describe('Element.getStyle', function(){ describe('Element.setStyle', function(){ it('should set the `styles` property on an Element using the Element constructor', function(){ - expect(new Element('div', {styles:{'color':'#00ff00'}}).getStyle('color')).toEqual('#00ff00'); + expect(new Element('div', {styles:{'color':'#00ff00'}}).getStyle('color')).to.equal('#00ff00'); }); it('should `setStyle` on an Element', function(){ - expect(new Element('div').setStyle('color','#00ff00').getStyle('color')).toEqual('#00ff00'); + expect(new Element('div').setStyle('color','#00ff00').getStyle('color')).to.equal('#00ff00'); }); it('should properly `setStyle` for a property with a dash in it', function(){ - expect(new Element('div').setStyle('list-style-type', 'square').getStyle('list-style-type')).toEqual('square'); + expect(new Element('div').setStyle('list-style-type', 'square').getStyle('list-style-type')).to.equal('square'); }); }); @@ -94,7 +94,7 @@ describe('Element.getStyles', function(){ it('should return multiple styles', function(){ var el = new Element('div').set('html', '
'); - expect(el.getElement('div').getStyles('color', 'list-style-type')).toEqual({color:'#00ff00', 'list-style-type':'square'}); + expect(el.getElement('div').getStyles('color', 'list-style-type')).to.deep.equal({color:'#00ff00', 'list-style-type':'square'}); }); }); @@ -102,7 +102,7 @@ describe('Element.getStyles', function(){ describe('Element.setStyles', function(){ it('should set multiple styles', function(){ - expect(new Element('div').setStyles({'list-style-type':'square', 'color':'#00ff00'}).getStyles('list-style-type', 'color')).toEqual({'list-style-type':'square', color:'#00ff00'}); + expect(new Element('div').setStyles({'list-style-type':'square', 'color':'#00ff00'}).getStyles('list-style-type', 'color')).to.deep.equal({'list-style-type':'square', color:'#00ff00'}); }); }); @@ -116,7 +116,7 @@ describe('Element.set opacity', function(){ if (!hasOpacity && document.html.style.filter != null && !window.opera && !syn.browser.gecko){ // we can probably remove the last two checks div.style.filter = 'blur(strength=50)'; div.set('opacity', 0.4); - expect(div.style.filter).toMatch(/blur\(strength=50\)/i); + expect(div.style.filter).to.match(/blur\(strength=50\)/i); } }); @@ -124,7 +124,7 @@ describe('Element.set opacity', function(){ var div = new Element('div'); div.set('opacity', 1e-20); div.set('opacity', 0.5); - expect(+div.get('opacity')).toEqual(0.5); + expect(+div.get('opacity')).to.equal(0.5); }); }); @@ -164,21 +164,21 @@ describe('Element.Style', function(){ }); it('should get the opacity defined by the CSS', function(){ - expect(this.element.getStyle('opacity')).toEqual(0.5); + expect(this.element.getStyle('opacity')).to.equal(0.5); }); it('should set/overwrite the opacity', function(){ this.element.setStyle('opacity', 1); - expect(this.element.getStyle('opacity')).toEqual(1); + expect(this.element.getStyle('opacity')).to.equal(1); this.element.setStyle('opacity', null); - expect(this.element.getStyle('opacity')).toEqual(0.5); + expect(this.element.getStyle('opacity')).to.equal(0.5); }); it('should remove the style by setting it to `null`', function(){ this.element.setStyle('color', '#FF9900'); - expect(this.element.getStyle('color')).toEqual('#ff9900'); + expect(this.element.getStyle('color')).to.equal('#ff9900'); this.element.setStyle('color', null); - expect(this.element.getStyle('color')).toEqual('#ff0000'); + expect(this.element.getStyle('color')).to.equal('#ff0000'); }); }); @@ -213,30 +213,30 @@ describe('Element.Style', function(){ }); it('should get the height from the CSS', function(){ - expect(element.getStyle('height')).toEqual('200px'); + expect(element.getStyle('height')).to.equal('200px'); }); it('should get the width from the CSS', function(){ - expect(element.getStyle('width')).toMatch(/\d+px/); + expect(element.getStyle('width')).to.match(/\d+px/); }); it('should not mangle the units from inline width in %', function(){ - expect(new Element('div').setStyle('width', '40%').getStyle('width')).toEqual('40%'); + expect(new Element('div').setStyle('width', '40%').getStyle('width')).to.equal('40%'); }); it('should not mangle the units from inline auto width', function(){ - expect(new Element('div').setStyle('width', 'auto').getStyle('width')).toEqual('auto'); + expect(new Element('div').setStyle('width', 'auto').getStyle('width')).to.equal('auto'); }); it('should get the left margin from the CSS', function(){ // FireFox returns px (and maybe even as floats) var re = /^(20\%|(\d+|\d+\.\d+)px)$/; - expect(re.test('20%')).toBe(true); - expect(re.test('20px')).toBe(true); - expect(re.test('20.43px')).toBe(true); - expect(re.test('20')).toBe(false); - expect(re.test('auto')).toBe(false); - expect(element.getStyle('margin-left')).toMatch(re); + expect(re.test('20%')).to.equal(true); + expect(re.test('20px')).to.equal(true); + expect(re.test('20.43px')).to.equal(true); + expect(re.test('20')).to.equal(false); + expect(re.test('auto')).to.equal(false); + expect(element.getStyle('margin-left')).to.match(re); }); it('[afterAll]', function(){ @@ -270,15 +270,15 @@ describe('Element.Style', function(){ }); it('should inherit the height from the child', function(){ - expect(element.getStyle('height')).toEqual('100px'); + expect(element.getStyle('height')).to.equal('100px'); }); it('should get a pixel based width', function(){ - expect(element.getStyle('width')).toMatch(/\d+px/); + expect(element.getStyle('width')).to.match(/\d+px/); }); it('should have a 0px border left', function(){ - expect(element.getStyle('borderLeftWidth')).toEqual('0px'); + expect(element.getStyle('borderLeftWidth')).to.equal('0px'); }); it('[afterAll]', function(){ @@ -291,7 +291,7 @@ describe('Element.Style', function(){ it('should have same order when getting a previously set border', function(){ var border = '2px solid #123abc'; - expect(new Element('div').setStyle('border', border).getStyle('border')).toEqual(border); + expect(new Element('div').setStyle('border', border).getStyle('border')).to.equal(border); }); }); @@ -299,7 +299,7 @@ describe('Element.Style', function(){ describe('getComputedStyle margin-left on detached element', function(){ it('should have a non-null margin-left', function(){ - expect(new Element('div').getComputedStyle('margin-left')).not.toEqual(null); + expect(new Element('div').getComputedStyle('margin-left')).to.not.equal(null); }); }); @@ -313,7 +313,7 @@ describe('Element.Style', function(){ } }); foo.setStyle('background-size', 20); - expect(foo.getStyle('backgroundSize')).toEqual('20px'); + expect(foo.getStyle('backgroundSize')).to.equal('20px'); }); }); @@ -348,19 +348,19 @@ describe('Element.Style', function(){ }); it('should have non-empty background-position shorthand', function(){ - expect(this.element.getStyle('background-position')).not.toEqual(null); - expect(this.element.getStyle('background-position')).toMatch(/\w+/); + expect(this.element.getStyle('background-position')).to.not.equal(null); + expect(this.element.getStyle('background-position')).to.match(/\w+/); }); it('should not return a keyword-based background-position shorthand', function(){ - expect(this.element.getStyle('background-position')).not.toMatch(/(top|right|bottom|left)/); - expect(this.element.getStyle('background-position')).toEqual('0% 100%'); + expect(this.element.getStyle('background-position')).to.not.match(/(top|right|bottom|left)/); + expect(this.element.getStyle('background-position')).to.equal('0% 100%'); }); it('should have non-empty background-position on an element with no set styles', function(){ var element = new Element('div'); - expect(element.getStyle('background-position')).not.toEqual(null); - expect(element.getStyle('background-position')).toMatch(/\w+/); + expect(element.getStyle('background-position')).to.not.equal(null); + expect(element.getStyle('background-position')).to.match(/\w+/); element = null; }); @@ -368,7 +368,7 @@ describe('Element.Style', function(){ var element = new Element('div'); element.setStyle('background-position', '40px 10px'); element.setStyle('background-position', null); - expect(element.getStyle('background-position')).toMatch(/0px 0px|0% 0%/); + expect(element.getStyle('background-position')).to.match(/0px 0px|0% 0%/); }); }); @@ -382,27 +382,27 @@ describe('Element.Style', function(){ dit("should set and read each borderRadius corner", function(){ - expect(element.getStyle('borderRadius')).toEqual('0px 0px 0px 0px'); + expect(element.getStyle('borderRadius')).to.equal('0px 0px 0px 0px'); element.setStyle('border-top-left-radius', '15px'); - expect(element.getStyle('border-top-left-radius')).toEqual('15px'); - expect(element.getStyle('borderRadius')).toEqual('15px 0px 0px 0px'); + expect(element.getStyle('border-top-left-radius')).to.equal('15px'); + expect(element.getStyle('borderRadius')).to.equal('15px 0px 0px 0px'); element.setStyle('border-radius', '10px'); - expect(element.getStyle('border-top-left-radius')).not.toEqual('15px'); - expect(element.getStyle('border-top-left-radius')).toEqual('10px'); + expect(element.getStyle('border-top-left-radius')).to.not.equal('15px'); + expect(element.getStyle('border-top-left-radius')).to.equal('10px'); element.setStyle('border-radius', '2em'); element.setStyle('border-bottom-left-radius', '1em'); - expect(element.getStyle('border-bottom-left-radius')).toEqual('1em'); - expect(element.getStyle('border-radius')).toEqual('2em 2em 2em 1em'); + expect(element.getStyle('border-bottom-left-radius')).to.equal('1em'); + expect(element.getStyle('border-radius')).to.equal('2em 2em 2em 1em'); element.setStyle('border-radius', '2px 2px 0px 0px'); - expect(element.getStyle('border-radius')).toEqual('2px 2px 0px 0px'); + expect(element.getStyle('border-radius')).to.equal('2px 2px 0px 0px'); element.setStyle('borderRadius', '10px'); element.setStyle('border-top-left-radius', '20px'); element.setStyle('border-bottom-left-radius', '0px'); - expect(element.getStyle('border-top-left-radius')).toEqual('20px'); - expect(element.getStyle('border-radius')).toEqual('20px 10px 10px 0px'); + expect(element.getStyle('border-top-left-radius')).to.equal('20px'); + expect(element.getStyle('border-radius')).to.equal('20px 10px 10px 0px'); }); element.destroy(); diff --git a/Specs/Element/Element.js b/Specs/Element/Element.js index 387c2365..2a562044 100644 --- a/Specs/Element/Element.js +++ b/Specs/Element/Element.js @@ -10,66 +10,66 @@ describe('Element constructor', function(){ it("should return an Element with the correct tag", function(){ var element = new Element('div'); - expect(typeOf(element)).toEqual('element'); - expect(element.getFirst).toBeDefined(); - expect(element.tagName.toLowerCase()).toEqual('div'); + expect(typeOf(element)).to.equal('element'); + expect(element.getFirst).to.not.equal(undefined); + expect(element.tagName.toLowerCase()).to.equal('div'); }); it('should return an Element with various attributes', function(){ var element = new Element('div', { 'id': 'divID', 'title': 'divTitle' }); - expect(element.id).toEqual('divID'); - expect(element.title).toEqual('divTitle'); + expect(element.id).to.equal('divID'); + expect(element.title).to.equal('divTitle'); }); it('should return an Element with for attribute', function(){ var label = new Element('label', { 'for': 'myId' }); - expect(label.htmlFor).toEqual('myId'); + expect(label.htmlFor).to.equal('myId'); }); it('should return an Element with class attribute', function(){ var div1 = new Element('div', { 'class': 'class' }); var div2 = new Element('div', { 'class': 'class1 class2 class3' }); - expect(div1.className).toEqual('class'); - expect(div2.className).toEqual('class1 class2 class3'); + expect(div1.className).to.equal('class'); + expect(div2.className).to.equal('class1 class2 class3'); }); it('should return input Elements with name and type attributes', function(){ var username = new Element('input', { type: 'text', name: 'username', value: 'username' }); var password = new Element('input', { type: 'password', name: 'password', value: 'password' }); - expect(username.type).toEqual('text'); - expect(username.name).toEqual('username'); - expect(username.value).toEqual('username'); + expect(username.type).to.equal('text'); + expect(username.name).to.equal('username'); + expect(username.value).to.equal('username'); - expect(password.type).toEqual('password'); - expect(password.name).toEqual('password'); - expect(password.value).toEqual('password'); + expect(password.type).to.equal('password'); + expect(password.name).to.equal('password'); + expect(password.value).to.equal('password'); var dad = new Element('div'); dad.adopt(username, password); dad.inject(document.body); - expect(document.getElementsByName('username')[0]).toEqual(username); - expect(document.getElementsByName('password')[0]).toEqual(password); + expect(document.getElementsByName('username')[0]).to.equal(username); + expect(document.getElementsByName('password')[0]).to.equal(password); dad.dispose(); }); it('should be able to use all kinds of silly characters in your name attribute values', function(){ ["foo","bar[]","b'a'z",'b"a"ng','boi ng'].each(function(name){ var input = new Element('input', { type: 'text', name: name, value: name }); - expect(input.type).toEqual('text'); - expect(input.name).toEqual(name); - expect(input.value).toEqual(name); + expect(input.type).to.equal('text'); + expect(input.name).to.equal(name); + expect(input.value).to.equal(name); var dad = new Element('div'); dad.adopt(input); dad.inject(document.body); - expect(document.getElementsByName(name)[0]).toEqual(input); + expect(document.getElementsByName(name)[0]).to.equal(input); dad.dispose(); }); }); it('should create an element with type="email"', function(){ var el = new Element('input', {type: 'email'}); - expect(el.get('type').match(/email|text/)).toBeTruthy(); + expect(el.get('type')).to.match(/email|text/); }); it('should return input Elements that are checked', function(){ @@ -77,9 +77,9 @@ describe('Element constructor', function(){ var check2 = new Element('input', { type: 'checkbox', checked: true }); var check3 = new Element('input', { type: 'checkbox', checked: 'checked' }); - expect(check1.checked).toBeFalsy(); - expect(check2.checked).toBeTruthy(); - expect(check3.checked).toBeTruthy(); + expect(check1.checked).to.not.be.ok; + expect(check2.checked).to.be.ok; + expect(check3.checked).to.be.ok; }); it("should return a select Element that retains it's selected options", function(){ @@ -102,12 +102,12 @@ describe('Element constructor', function(){ new Element('option', { name: 'bmw', value: 'bmw', html: 'BMW' }) ); - expect(select1.multiple).toBeTruthy(); - expect(select2.multiple).toBeTruthy(); + expect(select1.multiple).to.be.ok; + expect(select2.multiple).to.be.ok; - expect(select1.name).toEqual(select2.name); - expect(select1.options.length).toEqual(select2.options.length); - expect(select1.toQueryString()).toEqual(select2.toQueryString()); + expect(select1.name).to.equal(select2.name); + expect(select1.options.length).to.equal(select2.options.length); + expect(select1.toQueryString()).to.equal(select2.toQueryString()); }); }); @@ -116,66 +116,66 @@ describe('Element.set', function(){ it("should set a single attribute of an Element", function(){ var div = new Element('div').set('id', 'some_id'); - expect(div.id).toEqual('some_id'); + expect(div.id).to.equal('some_id'); }); it("should set the checked attribute of an Element", function(){ var input1 = new Element('input', {type: 'checkbox'}).set('checked', 'checked'); var input2 = new Element('input', {type: 'checkbox'}).set('checked', true); - expect(input1.checked).toBeTruthy(); - expect(input2.checked).toBeTruthy(); + expect(input1.checked).to.be.ok; + expect(input2.checked).to.be.ok; }); it("should set the class name of an element", function(){ var div = new Element('div').set('class', 'some_class'); - expect(div.className).toEqual('some_class'); + expect(div.className).to.equal('some_class'); }); it("should set the for attribute of an element", function(){ var input = new Element('label', {type: 'text'}).set('for', 'some_element'); - expect(input.htmlFor).toEqual('some_element'); + expect(input.htmlFor).to.equal('some_element'); }); it("should set the html of an Element", function(){ var html = 'Link'; var parent = new Element('div').set('html', html); - expect(parent.innerHTML.toLowerCase()).toEqual(html.toLowerCase()); + expect(parent.innerHTML.toLowerCase()).to.equal(html.toLowerCase()); }); it("should set the html of an Element with multiple arguments", function(){ var html = ['

Paragraph

', 'Link']; var parent = new Element('div').set('html', html); - expect(parent.innerHTML.toLowerCase()).toEqual(html.join('').toLowerCase()); + expect(parent.innerHTML.toLowerCase()).to.equal(html.join('').toLowerCase()); }); it("should set the html of a select Element", function(){ var html = ''; var select = new Element('select').set('html', html); - expect(select.getChildren().length).toEqual(2); - expect(select.options.length).toEqual(2); - expect(select.selectedIndex).toEqual(1); + expect(select.getChildren().length).to.equal(2); + expect(select.options.length).to.equal(2); + expect(select.selectedIndex).to.equal(1); }); it("should set the html of a table Element", function(){ var html = 'cell 1cell 2cell 1cell 2'; var table = new Element('table').set('html', html); - expect(table.getChildren().length).toEqual(1); - expect(table.getFirst().getFirst().getChildren().length).toEqual(2); - expect(table.getFirst().getLast().getFirst().className).toEqual('cell'); + expect(table.getChildren().length).to.equal(1); + expect(table.getFirst().getFirst().getChildren().length).to.equal(2); + expect(table.getFirst().getLast().getFirst().className).to.equal('cell'); }); it("should set the html of a tbody Element", function(){ var html = 'cell 1cell 2cell 1cell 2'; var tbody = new Element('tbody').inject(new Element('table')).set('html', html); - expect(tbody.getChildren().length).toEqual(2); - expect(tbody.getLast().getFirst().className).toEqual('cell'); + expect(tbody.getChildren().length).to.equal(2); + expect(tbody.getLast().getFirst().className).to.equal('cell'); }); it("should set the html of a tr Element", function(){ var html = 'cell 1cell 2'; var tr = new Element('tr').inject(new Element('tbody').inject(new Element('table'))).set('html', html); - expect(tr.getChildren().length).toEqual(2); - expect(tr.getFirst().className).toEqual('cell'); + expect(tr.getChildren().length).to.equal(2); + expect(tr.getFirst().className).to.equal('cell'); }); it("adopting should not change the parent of the element doing the adopting", function(){ @@ -184,51 +184,51 @@ describe('Element.set', function(){ gramps = baldGuy.getParent(); baldGuy.adopt(annie); - expect(baldGuy.getParent()).toEqual(gramps) + expect(baldGuy.getParent()).to.equal(gramps) }); it("should set the html of a td Element", function(){ var html = 'Some SpanSome Link'; var td = new Element('td').inject(new Element('tr').inject(new Element('tbody').inject(new Element('table')))).set('html', html); - expect(td.getChildren().length).toEqual(2); - expect(td.getFirst().className).toEqual('span'); + expect(td.getChildren().length).to.equal(2); + expect(td.getFirst().className).to.equal('span'); }); it("should set the style attribute of an Element", function(){ var style = 'font-size:12px;line-height:23px;'; var div = new Element('div').set('style', style); - expect(div.style.lineHeight).toEqual('23px'); - expect(div.style.fontSize).toEqual('12px'); + expect(div.style.lineHeight).to.equal('23px'); + expect(div.style.fontSize).to.equal('12px'); }); it("should set the text of an element", function(){ var div = new Element('div').set('text', 'some text content'); - expect(div.get('text')).toEqual('some text content'); - expect(div.innerHTML).toEqual('some text content'); + expect(div.get('text')).to.equal('some text content'); + expect(div.innerHTML).to.equal('some text content'); }); it("should set multiple attributes of an Element", function(){ var div = new Element('div').set({ id: 'some_id', 'title': 'some_title', 'html': 'some_content' }); - expect(div.id).toEqual('some_id'); - expect(div.title).toEqual('some_title'); - expect(div.innerHTML).toEqual('some_content'); + expect(div.id).to.equal('some_id'); + expect(div.title).to.equal('some_title'); + expect(div.innerHTML).to.equal('some_content'); }); it("should set various attributes of a script Element", function(){ var script = new Element('script').set({ type: 'text/javascript', defer: 'defer' }); - expect(script.type).toEqual('text/javascript'); - expect(script.defer).toBeTruthy(); + expect(script.type).to.equal('text/javascript'); + expect(script.defer).to.be.ok; }); it("should set various attributes of a table Element", function(){ var table1 = new Element('table').set({ border: '2', cellpadding: '3', cellspacing: '4', align: 'center' }); var table2 = new Element('table').set({ cellPadding: '3', cellSpacing: '4' }); - expect(table1.border == 2).toBeTruthy(); - expect(table1.cellPadding == 3).toBeTruthy(); - expect(table2.cellPadding == 3).toBeTruthy(); - expect(table1.cellSpacing == 4).toBeTruthy(); - expect(table2.cellSpacing == 4).toBeTruthy(); - expect(table1.align).toEqual('center'); + expect(table1.border == 2).to.be.ok; + expect(table1.cellPadding == 3).to.be.ok; + expect(table2.cellPadding == 3).to.be.ok; + expect(table1.cellSpacing == 4).to.be.ok; + expect(table2.cellSpacing == 4).to.be.ok; + expect(table1.align).to.equal('center'); }); }); @@ -243,33 +243,36 @@ describe('Elements', function(){ //<1.3compat> it('should return an array type', function(){ - expect(Array.type(myElements)).toBeTruthy(); + expect(Array.type(myElements)).to.equal(true); }); // it('should return an elements type', function(){ - expect(typeOf(myElements) == 'elements').toBeTruthy(); + expect(typeOf(myElements)).to.equal('elements'); }); it('should return an array of Elements', function(){ - expect(myElements.every(function(e){ return typeOf(e) == 'element'; })).toBeTruthy(); + expect(myElements.every(function(e){ return typeOf(e) == 'element'; })).to.equal(true); }); it('should apply Element prototypes to the returned array', function(){ - expect(myElements.getFirst).toBeDefined(); + expect(myElements.getFirst).to.not.equal(undefined); }); it('should return all Elements that match the string matcher', function(){ var filter = myElements.filter('div'); - expect(filter[0] == myElements[0] && filter[1] == myElements[2] && filter.length == 2).toBeTruthy(); + expect(filter[0]).to.equal(myElements[0]); + expect(filter[1]).to.equal(myElements[2]); + expect(filter.length).to.equal(2); }); it('should return all Elements that match the comparator', function(){ var elements = myElements.filter(function(element){ return element.match('a'); }); - expect(elements[0] == myElements[1] && elements.length == 1).toBeTruthy(); + expect(elements[0]).to.equal(myElements[1]); + expect(elements.length).to.equal(1); }); }); @@ -278,7 +281,7 @@ describe('TextNode.constructor', function(){ it('should return a new textnode element', function(){ var text = document.newTextNode('yo'); - expect(typeOf(text)).toEqual('textnode'); + expect(typeOf(text)).to.equal('textnode'); }); }); @@ -288,13 +291,13 @@ describe('IFrame constructor', function(){ it('should return a new IFrame', function(){ var iFrame1 = document.createElement('iframe'); var iFrame2 = new IFrame(); - expect(iFrame1.tagName).toEqual(iFrame2.tagName); + expect(iFrame1.tagName).to.equal(iFrame2.tagName); }); it('should return the same IFrame if passed', function(){ var iFrame1 = document.createElement('iframe'); var iFrame2 = new IFrame(iFrame1); - expect(iFrame1).toEqual(iFrame2); + expect(iFrame1).to.equal(iFrame2); }); }); @@ -316,22 +319,22 @@ describe('$', function(){ var dollar1 = document.getElementById('dollar'); var dollar2 = $('dollar'); - expect(dollar1).toEqual(dollar2); - expect(dollar1.getFirst).toBeDefined(); + expect(dollar1).to.equal(dollar2); + expect(dollar1.getFirst).to.not.equal(undefined); }); it('should return the window if passed', function(){ var win = $(window); - expect(win == window).toBeTruthy(); + expect(win == window).to.equal(true); }); it('should return the document if passed', function(){ - expect($(document)).toEqual(document); + expect($(document)).to.equal(document); }); it('should return null if string not found or type mismatch', function(){ - expect($(1)).toBeNull(); - expect($('nonexistant')).toBeNull(); + expect($(1)).to.equal(null); + expect($('nonexistant')).to.equal(null); }); }); @@ -352,7 +355,7 @@ describe('$$', function(){ it('should return all Elements of a specific tag', function(){ var divs1 = $$('div'); var divs2 = new Elements(Array.from(document.getElementsByTagName('div'))); - expect(divs1).toEqual(divs2); + expect(divs1).to.deep.equal(divs2); }); it('should return multiple Elements for each specific tag', function(){ @@ -363,11 +366,11 @@ describe('$$', function(){ }; var headers1 = $$('h3, h4').sort(sortBy); var headers2 = new Elements(Array.flatten([document.getElementsByTagName('h3'), document.getElementsByTagName('h4')])).sort(sortBy); - expect(headers1).toEqual(headers2); + expect(headers1).to.deep.equal(headers2); }); it('should return an empty array if not is found', function(){ - expect($$('not_found')).toEqual(new Elements([])); + expect($$('not_found')).to.deep.equal(new Elements([])); }); afterEach(function(){ @@ -382,17 +385,17 @@ describe('getDocument', function(){ it('should return the owner document for elements', function(){ var doc = document.newElement('div').getDocument(); - expect(doc).toEqual(document); + expect(doc).to.equal(document); }); it('should return the owned document for window', function(){ var doc = window.getDocument(); - expect(doc).toEqual(document); + expect(doc).to.equal(document); }); it('should return self for document', function(){ var doc = document.getDocument(); - expect(doc).toEqual(document); + expect(doc).to.equal(document); }); }); @@ -401,17 +404,17 @@ describe('getWindow', function(){ it('should return the owner window for elements', function(){ var win = document.newElement('div').getWindow(); - expect(win == window).toBeTruthy(); + expect(win).to.equal(window); }); it('should return the owner window for document', function(){ var win = document.getWindow(); - expect(win == window).toBeTruthy(); + expect(win).to.equal(window); }); it('should return self for window', function(){ var win = window.getWindow(); - expect(win == window).toBeTruthy(); + expect(win == window).to.equal(true); }); }); @@ -429,8 +432,8 @@ describe('Element.getElement', function(){ it('should return the first Element to match the tag, otherwise null', function(){ var child = Container.getElement('div'); - expect(child.id).toEqual('first'); - expect(Container.getElement('iframe')).toBeNull(); + expect(child.id).to.equal('first'); + expect(Container.getElement('iframe')).to.equal(null); }); }); @@ -448,13 +451,13 @@ describe('Element.getElements', function(){ it('should return all the elements that match the tag', function(){ var children = Container.getElements('div'); - expect(children.length).toEqual(2); + expect(children.length).to.equal(2); }); it('should return all the elements that match the tags', function(){ var children = Container.getElements('div,a'); - expect(children.length).toEqual(3); - expect(children[2].tagName.toLowerCase()).toEqual('a'); + expect(children.length).to.equal(3); + expect(children[2].tagName.toLowerCase()).to.equal('a'); }); }); @@ -464,10 +467,10 @@ describe('Document.getElement', function(){ it('should return the first Element to match the tag, otherwise null', function(){ var div = document.getElement('div'); var ndiv = document.getElementsByTagName('div')[0]; - expect(div).toEqual(ndiv); + expect(div).to.equal(ndiv); var notfound = document.getElement('canvas'); - expect(notfound).toBeNull(); + expect(notfound).to.equal(null); }); }); @@ -477,13 +480,13 @@ describe('Document.getElements', function(){ it('should return all the elements that match the tag', function(){ var divs = document.getElements('div'); var ndivs = new Elements(document.getElementsByTagName('div')); - expect(divs).toEqual(ndivs); + expect(divs).to.deep.equal(ndivs); }); it('should return all the elements that match the tags', function(){ var headers = document.getElements('h3,h4'); var headers2 = new Elements(Array.flatten([document.getElementsByTagName('h3'), document.getElementsByTagName('h4')])); - expect(headers.length).toEqual(headers2.length); + expect(headers.length).to.equal(headers2.length); }); }); @@ -502,8 +505,8 @@ describe('Element.getElementById', function(){ }); it('should getElementById that matches the id, otherwise null', function(){ - expect(Container.getElementById('first')).toEqual(Container.childNodes[0]); - expect(Container.getElementById('not_found')).toBeNull(); + expect(Container.getElementById('first')).to.equal(Container.childNodes[0]); + expect(Container.getElementById('not_found')).to.equal(null); }); }); @@ -513,7 +516,7 @@ describe('Element.get style', function(){ it("should return a CSS string representing the Element's styles", function(){ var style = 'font-size:12px;color:rgb(255,255,255)'; var myElement = new Element('div').set('style', style); - expect(myElement.get('style').toLowerCase().replace(/\s/g, '').replace(/;$/, '')).toMatch(/(font-size:12px;color:rgb\(255,255,255\))|(color:rgb\(255,255,255\);font-size:12px)/); + expect(myElement.get('style').toLowerCase().replace(/\s/g, '').replace(/;$/, '')).to.match(/(font-size:12px;color:rgb\(255,255,255\))|(color:rgb\(255,255,255\);font-size:12px)/); //I'm replacing these characters (space and the last semicolon) as they are not vital to the style, and browsers sometimes include them, sometimes not. }); @@ -523,7 +526,7 @@ describe('Element.get tag', function(){ it("should return the Element's tag", function(){ var myElement = new Element('div'); - expect(myElement.get('tag')).toEqual('div'); + expect(myElement.get('tag')).to.equal('div'); }); }); @@ -532,27 +535,27 @@ describe('Element.get', function(){ it("should get an absolute href", function(){ var link = new Element('a', {href: "http://google.com/"}); - expect(link.get('href')).toEqual("http://google.com/"); + expect(link.get('href')).to.equal("http://google.com/"); }); it("should get an absolute href to the same domain", function(){ var link = new Element('a', {href: window.location.href}); - expect(link.get('href')).toEqual(window.location.href); + expect(link.get('href')).to.equal(window.location.href); }); it("should get a relative href", function(){ var link = new Element('a', {href: "../index.html"}); - expect(link.get('href')).toEqual("../index.html"); + expect(link.get('href')).to.equal("../index.html"); }); it("should get a host absolute href", function(){ var link = new Element('a', {href: "/developers"}); - expect(link.get('href')).toEqual("/developers"); + expect(link.get('href')).to.equal("/developers"); }); it("should return null when attribute is missing", function(){ var link = new Element('a'); - expect(link.get('href')).toBeNull(); + expect(link.get('href')).to.equal(null); }); }); @@ -561,14 +564,14 @@ describe('Element.erase', function(){ it("should erase an Element's property", function(){ var myElement = new Element('a', {href: 'http://mootools.net/', title: 'mootools!'}); - expect(myElement.get('title')).toEqual('mootools!'); - expect(myElement.erase('title').get('title')).toBeNull(); + expect(myElement.get('title')).to.equal('mootools!'); + expect(myElement.erase('title').get('title')).to.equal(null); }); it("should erase an Element's style", function(){ var myElement = new Element('div', {style: "color:rgb(255, 255, 255); font-size:12px;"}); myElement.erase('style'); - expect(myElement.get('style')).toEqual(''); + expect(myElement.get('style')).to.equal(''); }); }); @@ -577,12 +580,12 @@ describe('Element.match', function(){ it('should return true if tag is not provided', function(){ var element = new Element('div'); - expect(element.match()).toBeTruthy(); + expect(element.match()).to.equal(true); }); it("should return true if the Element's tag matches", function(){ var element = new Element('div'); - expect(element.match('div')).toBeTruthy(); + expect(element.match('div')).to.equal(true); }); }); @@ -612,66 +615,66 @@ describe('Element.inject', function(){ it('should inject the Element before an Element', function(){ test.inject($('first'), 'before'); - expect(Container.childNodes[0]).toEqual(test); + expect(Container.childNodes[0]).to.equal(test); test.inject($('second-child'), 'before'); - expect(Container.childNodes[1].childNodes[1]).toEqual(test); + expect(Container.childNodes[1].childNodes[1]).to.equal(test); }); it('should inject the Element after an Element', function(){ test.inject($('first'), 'after'); - expect(Container.childNodes[1]).toEqual(test); + expect(Container.childNodes[1]).to.equal(test); test.inject($('first-child'), 'after'); - expect(Container.childNodes[1].childNodes[1]).toEqual(test); + expect(Container.childNodes[1].childNodes[1]).to.equal(test); }); it('should inject the Element at bottom of an Element', function(){ var first = $('first'); test.inject(first, 'bottom'); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second'); test.inject(second, 'bottom'); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); test.inject(Container, 'bottom'); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); it('should inject the Element inside an Element', function(){ var first = $('first'); test.inject(first, 'inside'); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second'); test.inject(second, 'inside'); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); test.inject(Container, 'inside'); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); it('should inject the Element at the top of an Element', function(){ test.inject(Container, 'top'); - expect(Container.childNodes[0]).toEqual(test); + expect(Container.childNodes[0]).to.equal(test); var second = $('second'); test.inject(second, 'top'); - expect(second.childNodes[0]).toEqual(test); + expect(second.childNodes[0]).to.equal(test); }); it('should inject the Element in an Element', function(){ var first = $('first'); test.inject(first); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second'); test.inject(second); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); test.inject(Container); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); }); @@ -683,7 +686,7 @@ describe('Element.replaces', function(){ var div = new Element('div', {id: 'original'}).inject(parent); var el = new Element('div', {id: 'replaced'}); el.replaces(div); - expect(parent.childNodes[0]).toEqual(el); + expect(parent.childNodes[0]).to.equal(el); }); }); @@ -712,64 +715,64 @@ describe('Element.grab', function(){ it('should grab the Element before this Element', function(){ $('first').grab(test, 'before'); - expect(Container.childNodes[0]).toEqual(test); + expect(Container.childNodes[0]).to.equal(test); $('second-child').grab(test, 'before'); - expect(Container.childNodes[1].childNodes[1]).toEqual(test); + expect(Container.childNodes[1].childNodes[1]).to.equal(test); }); it('should grab the Element after this Element', function(){ $('first').grab(test, 'after'); - expect(Container.childNodes[1]).toEqual(test); + expect(Container.childNodes[1]).to.equal(test); $('first-child').grab(test, 'after'); - expect(Container.childNodes[1].childNodes[1]).toEqual(test); + expect(Container.childNodes[1].childNodes[1]).to.equal(test); }); it('should grab the Element at the bottom of this Element', function(){ var first = $('first'); first.grab(test, 'bottom'); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second'); second.grab(test, 'bottom'); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); Container.grab(test, 'bottom'); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); it('should grab the Element inside this Element', function(){ var first = $('first'); first.grab(test, 'inside'); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second'); second.grab(test, 'inside'); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); Container.grab(test, 'inside'); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); it('should grab the Element at the top of this Element', function(){ Container.grab(test, 'top'); - expect(Container.childNodes[0]).toEqual(test); + expect(Container.childNodes[0]).to.equal(test); var second = $('second'); second.grab(test, 'top'); - expect(second.childNodes[0]).toEqual(test); + expect(second.childNodes[0]).to.equal(test); }); it('should grab an Element in the Element', function(){ var first = $('first').grab(test); - expect(first.childNodes[0]).toEqual(test); + expect(first.childNodes[0]).to.equal(test); var second = $('second').grab(test); - expect(second.childNodes[2]).toEqual(test); + expect(second.childNodes[2]).to.equal(test); Container.grab(test); - expect(Container.childNodes[2]).toEqual(test); + expect(Container.childNodes[2]).to.equal(test); }); }); @@ -781,8 +784,8 @@ describe('Element.wraps', function(){ var child = new Element('p').inject(div); var wrapper = new Element('div', {id: 'wrapper'}).wraps(div.childNodes[0]); - expect(div.childNodes[0]).toEqual(wrapper); - expect(wrapper.childNodes[0]).toEqual(child); + expect(div.childNodes[0]).to.equal(wrapper); + expect(wrapper.childNodes[0]).to.equal(child); }); }); @@ -810,64 +813,64 @@ describe('Element.appendText', function(){ it('should append a TextNode before this Element', function(){ $('first').appendText('test', 'before'); - expect(Container.childNodes[0].nodeValue).toEqual('test'); + expect(Container.childNodes[0].nodeValue).to.equal('test'); $('second-child').appendText('test', 'before'); - expect(Container.childNodes[2].childNodes[1].nodeValue).toEqual('test'); + expect(Container.childNodes[2].childNodes[1].nodeValue).to.equal('test'); }); it('should append a TextNode the Element after this Element', function(){ $('first').appendText('test', 'after'); - expect(Container.childNodes[1].nodeValue).toEqual('test'); + expect(Container.childNodes[1].nodeValue).to.equal('test'); $('first-child').appendText('test', 'after'); - expect(Container.childNodes[2].childNodes[1].nodeValue).toEqual('test'); + expect(Container.childNodes[2].childNodes[1].nodeValue).to.equal('test'); }); it('should append a TextNode the Element at the bottom of this Element', function(){ var first = $('first'); first.appendText('test', 'bottom'); - expect(first.childNodes[0].nodeValue).toEqual('test'); + expect(first.childNodes[0].nodeValue).to.equal('test'); var second = $('second'); second.appendText('test', 'bottom'); - expect(second.childNodes[2].nodeValue).toEqual('test'); + expect(second.childNodes[2].nodeValue).to.equal('test'); Container.appendText('test', 'bottom'); - expect(Container.childNodes[2].nodeValue).toEqual('test'); + expect(Container.childNodes[2].nodeValue).to.equal('test'); }); it('should append a TextNode the Element inside this Element', function(){ var first = $('first'); first.appendText('test', 'inside'); - expect(first.childNodes[0].nodeValue).toEqual('test'); + expect(first.childNodes[0].nodeValue).to.equal('test'); var second = $('second'); second.appendText('test', 'inside'); - expect(second.childNodes[2].nodeValue).toEqual('test'); + expect(second.childNodes[2].nodeValue).to.equal('test'); Container.appendText('test', 'inside'); - expect(Container.childNodes[2].nodeValue).toEqual('test'); + expect(Container.childNodes[2].nodeValue).to.equal('test'); }); it('should append a TextNode the Element at the top of this Element', function(){ Container.appendText('test', 'top'); - expect(Container.childNodes[0].nodeValue).toEqual('test'); + expect(Container.childNodes[0].nodeValue).to.equal('test'); var second = $('second'); second.appendText('test', 'top'); - expect(second.childNodes[0].nodeValue).toEqual('test'); + expect(second.childNodes[0].nodeValue).to.equal('test'); }); it('should append a TextNode an Element in the Element', function(){ var first = $('first').appendText('test'); - expect(first.childNodes[0].nodeValue).toEqual('test'); + expect(first.childNodes[0].nodeValue).to.equal('test'); var second = $('second').appendText('test'); - expect(second.childNodes[2].nodeValue).toEqual('test'); + expect(second.childNodes[2].nodeValue).to.equal('test'); Container.appendText('test'); - expect(Container.childNodes[2].nodeValue).toEqual('test'); + expect(Container.childNodes[2].nodeValue).to.equal('test'); }); }); @@ -890,21 +893,21 @@ describe('Element.adopt', function(){ var child = new Element('div', {id: 'adopt-me'}); document.body.appendChild(child); Container.adopt('adopt-me'); - expect(Container.childNodes[0]).toEqual(child); + expect(Container.childNodes[0]).to.equal(child); }); it('should adopt an Element', function(){ var child = new Element('p'); Container.adopt(child); - expect(Container.childNodes[0]).toEqual(child); + expect(Container.childNodes[0]).to.equal(child); }); it('should adopt any number of Elements or ids', function(){ var children = []; (100).times(function(i){ children[i] = new Element('span', {id: 'child-' + i}); }); Container.adopt(children); - expect(Container.childNodes.length).toEqual(100); - expect(Container.childNodes[10]).toEqual(children[10]); + expect(Container.childNodes.length).to.equal(100); + expect(Container.childNodes[10]).to.equal(children[10]); }); }); @@ -916,7 +919,7 @@ describe('Element.dispose', function(){ var child = new Element('div').inject(Container); child.dispose(); - expect(Container.childNodes.length).toEqual(0); + expect(Container.childNodes.length).to.equal(0); document.body.removeChild(Container); Container.set('html', ''); @@ -939,35 +942,35 @@ describe('Element.clone', function(){ it('should return a clone', function(){ var div = new Element('div'); var clone = div.clone(); - expect(div).not.toBe(clone); - expect(typeOf(div)).toEqual('element'); - expect(typeOf(clone)).toEqual('element'); + expect(div).to.not.equal(clone); + expect(typeOf(div)).to.equal('element'); + expect(typeOf(clone)).to.equal('element'); }); it('should remove id from clone and clone children by default', function(){ var clone = Container.clone(); - expect(clone.getElementsByTagName('*').length).toEqual(3); - expect(clone.className).toEqual('moo'); - expect(clone.id).toEqual(''); - expect(Container.id).toEqual('outer'); + expect(clone.getElementsByTagName('*').length).to.equal(3); + expect(clone.className).to.equal('moo'); + expect(clone.id).to.equal(''); + expect(Container.id).to.equal('outer'); }); it('should remove all ids', function(){ var clone = Container.clone(true); - expect(clone.id).toEqual(''); - expect(clone.childNodes.length).toEqual(2); - expect(clone.childNodes[0].id).toEqual(''); - expect(clone.childNodes[0].childNodes[0].id).toEqual(''); - expect(clone.childNodes[0].className).toEqual('foo'); + expect(clone.id).to.equal(''); + expect(clone.childNodes.length).to.equal(2); + expect(clone.childNodes[0].id).to.equal(''); + expect(clone.childNodes[0].childNodes[0].id).to.equal(''); + expect(clone.childNodes[0].className).to.equal('foo'); }); it('should keep id if specified', function(){ var clone = Container.clone(true, true); - expect(clone.id).toEqual('outer'); - expect(clone.childNodes.length).toEqual(2); - expect(clone.childNodes[0].id).toEqual('inner1'); - expect(clone.childNodes[0].childNodes[0].id).toEqual('sixfeet'); - expect(clone.childNodes[0].className).toEqual('foo'); + expect(clone.id).to.equal('outer'); + expect(clone.childNodes.length).to.equal(2); + expect(clone.childNodes[0].id).to.equal('inner1'); + expect(clone.childNodes[0].childNodes[0].id).to.equal('sixfeet'); + expect(clone.childNodes[0].className).to.equal('foo'); }); it('should clone empty href attribute', function(){ @@ -975,23 +978,23 @@ describe('Element.clone', function(){ html: 'empty anchor' }).getFirst().clone(); - expect(clone.getAttribute('href', 2)).toEqual(''); + expect(clone.getAttribute('href', 2)).to.equal(''); }); it('should not clone Element Storage', function(){ Container.store('drink', 'milk'); var clone = Container.clone(); - expect(clone.retrieve('drink')).toBeNull(); - expect(Container.retrieve('drink')).toEqual('milk'); + expect(clone.retrieve('drink')).to.equal(null); + expect(Container.retrieve('drink')).to.equal('milk'); }); //<1.2compat> it('should clone child nodes and not copy their uid', function(){ var cloned = Container.clone(true).getElements('*'); var old = Container.getElements('*'); - expect(cloned.length).toEqual(3); - expect(old.length).toEqual(3); - expect($$(old, cloned).length).toEqual(6); + expect(cloned.length).to.equal(3); + expect(old.length).to.equal(3); + expect($$(old, cloned).length).to.equal(6); }); // @@ -999,9 +1002,9 @@ describe('Element.clone', function(){ dit('should clone child nodes and not copy their uid', function(){ var cloned = Container.clone(true).getElements('*'); var old = Container.getElements('*'); - expect(cloned.length).toEqual(3); - expect(old.length).toEqual(3); - expect(new Elements([old, cloned]).length).toEqual(2); + expect(cloned.length).to.equal(3); + expect(old.length).to.equal(3); + expect(new Elements([old, cloned]).length).to.equal(2); }); it('should clone a text input and retain value', function(){ @@ -1013,10 +1016,10 @@ describe('Element.clone', function(){ var input1 = inputs[0].clone(); var input2 = inputs[1].clone(false, true); - expect(!input1.id).toBeTruthy(); - expect(input2.id).toEqual('input2'); - expect(input1.value).toEqual('Some Value'); - expect(input2.value).toEqual(''); + expect(input1.id).to.not.be.ok; + expect(input2.id).to.equal('input2'); + expect(input1.value).to.equal('Some Value'); + expect(input2.value).to.equal(''); }); it('should clone a textarea and retain value', function(){ @@ -1028,10 +1031,10 @@ describe('Element.clone', function(){ var textarea1 = textareas[0].clone(); var textarea2 = textareas[1].clone(false, true); - expect(!textarea1.id).toBeTruthy(); - expect(textarea2.id).toEqual('textarea2'); - expect(textarea1.value).toEqual(''); - expect(textarea2.value).toEqual('Some-Text-Here'); + expect(textarea1.id).to.not.be.ok; + expect(textarea2.id).to.equal('textarea2'); + expect(textarea1.value).to.equal(''); + expect(textarea2.value).to.equal('Some-Text-Here'); }); it('should clone a checkbox and retain checked state', function(){ @@ -1043,10 +1046,10 @@ describe('Element.clone', function(){ var check1 = checks[0].clone(); var check2 = checks[1].clone(false, true); - expect(!check1.id).toBeTruthy(); - expect(check2.id).toEqual('check2'); - expect(check1.checked).toBeFalsy(); - expect(check2.checked).toBeTruthy(); + expect(check1.id).to.not.be.ok; + expect(check2.id).to.equal('check2'); + expect(check1.checked).to.not.be.ok; + expect(check2.checked).to.be.ok; }); it('should clone a select and retain selected state', function(){ @@ -1070,18 +1073,18 @@ describe('Element.clone', function(){ var select1 = selects[0].clone(true); var select2 = selects[1].clone(true, true); - expect(!select1.id).toBeTruthy(); - expect(select2.id).toEqual('select2'); - expect(select1.selectedIndex).toEqual(3); - expect(select2.options[3].selected).toBeTruthy(); - expect(select2.options[4].selected).toBeTruthy(); + expect(select1.id).to.not.be.ok; + expect(select2.id).to.equal('select2'); + expect(select1.selectedIndex).to.equal(3); + expect(select2.options[3].selected).to.be.ok; + expect(select2.options[4].selected).to.be.ok; }); it('should clone custom attributes', function(){ var div = new Element('div'); div.setAttribute('foo', 'FOO'); - expect(div.clone().getAttribute('foo')).toEqual('FOO'); + expect(div.clone().getAttribute('foo')).to.equal('FOO'); }); }); @@ -1090,57 +1093,58 @@ describe('Element className methods', function(){ it('should return true if the Element has the given class', function(){ var div = new Element('div', {'class': 'header bold\tunderline'}); - expect(div.hasClass('header')).toBeTruthy(); - expect(div.hasClass('bold')).toBeTruthy(); - expect(div.hasClass('underline')).toBeTruthy(); + expect(div.hasClass('header')).to.equal(true); + expect(div.hasClass('bold')).to.equal(true); + expect(div.hasClass('underline')).to.equal(true); }); it('should return false if the element does not have the given class', function(){ var div = new Element('div', {'class': 'header bold'}); - expect(div.hasClass('italics')).toBeFalsy(); - expect(div.hasClass('head')).toBeFalsy(); + expect(div.hasClass('italics')).to.equal(false); + expect(div.hasClass('head')).to.equal(false); }); it('should add the class to the Element', function(){ var div = new Element('div'); div.addClass('myclass'); - expect(div.hasClass('myclass')).toBeTruthy(); + expect(div.hasClass('myclass')).to.equal(true); }); it('should append classes to the Element', function(){ var div = new Element('div', {'class': 'myclass'}); div.addClass('aclass'); - expect(div.hasClass('aclass')).toBeTruthy(); + expect(div.hasClass('aclass')).to.equal(true); }); it('should remove the class in the Element', function(){ var div = new Element('div', {'class': 'myclass'}); div.removeClass('myclass'); - expect(div.hasClass('myclass')).toBeFalsy(); + expect(div.hasClass('myclass')).to.equal(false); }); it('should only remove the specific class', function(){ var div = new Element('div', {'class': 'myclass aclass'}); div.removeClass('myclass'); - expect(div.hasClass('myclass')).toBeFalsy(); + expect(div.hasClass('myclass')).to.equal(false); + expect(div.hasClass('aclass')).to.equal(true); }); it('should not remove any class if the class is not found', function(){ var div = new Element('div', {'class': 'myclass'}); div.removeClass('extra'); - expect(div.hasClass('myclass')).toBeTruthy(); + expect(div.hasClass('myclass')).to.equal(true); }); it('should add the class if the Element does not have the class', function(){ var div = new Element('div'); div.toggleClass('myclass'); - expect(div.hasClass('myclass')).toBeTruthy(); + expect(div.hasClass('myclass')).to.equal(true); }); it('should remove the class if the Element does have the class', function(){ var div = new Element('div', {'class': 'myclass'}); div.toggleClass('myclass'); - expect(div.hasClass('myclass')).toBeFalsy(); + expect(div.hasClass('myclass')).to.equal(false); }); }); @@ -1152,7 +1156,7 @@ describe('Element.empty', function(){ (5).times(function(i){ children[i] = new Element('p'); }); var div = new Element('div').adopt(children); div.empty(); - expect(div.get('html')).toEqual(''); + expect(div.get('html')).to.equal(''); }); }); @@ -1162,8 +1166,8 @@ describe('Element.destroy', function(){ it('should obliterate the Element from the universe', function(){ var div = new Element('div', {id: 'destroy-test'}).inject(document.body); var result = div.destroy(); - expect(result).toBeNull(); - expect($('destroy-test')).toBeNull(); + expect(result).to.equal(null); + expect($('destroy-test')).to.equal(null); }); }); @@ -1172,7 +1176,7 @@ describe('Element.toQueryString', function(){ it('should return an empty string for an Element that does not have form Elements', function(){ var div = new Element('div'); - expect(div.toQueryString()).toEqual(''); + expect(div.toQueryString()).to.equal(''); }); it('should ignore any form Elements that do not have a name, disabled, or whose value is false', function(){ @@ -1184,7 +1188,7 @@ describe('Element.toQueryString', function(){ ), new Element('textarea', { name: 'textarea', disabled: true, value: 'textarea-value' }) ); - expect(form.toQueryString()).toEqual(''); + expect(form.toQueryString()).to.equal(''); }); it("should return a query string containing even empty values, multiple select may have no selected options", function(){ @@ -1199,7 +1203,7 @@ describe('Element.toQueryString', function(){ '' + '' }); - expect(form.toQueryString()).toEqual('input=&textarea='); + expect(form.toQueryString()).to.equal('input=&textarea='); }); it("should return a query string ignoring submit, reset and file form Elements", function(){ @@ -1210,7 +1214,7 @@ describe('Element.toQueryString', function(){ '' + '' }); - expect(form.toQueryString()).toEqual('input=checked&textarea=textarea-value'); + expect(form.toQueryString()).to.equal('input=checked&textarea=textarea-value'); }); }); @@ -1220,19 +1224,19 @@ describe('Element.getProperty', function(){ it('should getProperty from an Element', function(){ var anchor1 = new Element('a'); anchor1.href = 'http://mootools.net'; - expect(anchor1.getProperty('href')).toEqual('http://mootools.net'); + expect(anchor1.getProperty('href')).to.equal('http://mootools.net'); var anchor2 = new Element('a'); anchor2.href = '#someLink'; - expect(anchor2.getProperty('href')).toEqual('#someLink'); + expect(anchor2.getProperty('href')).to.equal('#someLink'); }); it('should getProperty type of an input Element', function(){ var input1 = new Element('input', {type: 'text'}); - expect(input1.getProperty('type')).toEqual('text'); + expect(input1.getProperty('type')).to.equal('text'); var input2 = new Element('input', {type: 'checkbox'}); - expect(input2.getProperty('type')).toEqual('checkbox'); + expect(input2.getProperty('type')).to.equal('checkbox'); var div = new Element('div', {'html': '' }); var input3 = div.getElement('select'); - expect(input3.getProperty('type')).toEqual('select-multiple'); - expect(input3.getProperty('name')).toEqual('test'); + expect(input3.getProperty('type')).to.equal('select-multiple'); + expect(input3.getProperty('name')).to.equal('test'); }); it('should getPropety checked from an input Element', function(){ var checked1 = new Element('input', { type: 'checkbox' }); checked1.checked = 'checked'; - expect(checked1.getProperty('checked')).toBeTruthy(); + expect(checked1.getProperty('checked')).to.be.ok; var checked2 = new Element('input', { type: 'checkbox' }); checked2.checked = true; - expect(checked2.getProperty('checked')).toBeTruthy(); + expect(checked2.getProperty('checked')).to.be.ok; var checked3 = new Element('input', { type: 'checkbox' }); checked3.checked = false; - expect(checked3.getProperty('checked')).toBeFalsy(); + expect(checked3.getProperty('checked')).to.not.be.ok; }); it('should getProperty disabled from an input Element', function(){ var disabled1 = new Element('input', { type: 'text' }); disabled1.disabled = 'disabled'; - expect(disabled1.getProperty('disabled')).toBeTruthy(); + expect(disabled1.getProperty('disabled')).to.be.ok; var disabled2 = new Element('input', { type: 'text' }); disabled2.disabled = true; - expect(disabled2.getProperty('disabled')).toBeTruthy(); + expect(disabled2.getProperty('disabled')).to.be.ok; var disabled3 = new Element('input', { type: 'text' }); disabled3.disabled = false; - expect(disabled3.getProperty('disabled')).toBeFalsy(); + expect(disabled3.getProperty('disabled')).to.not.be.ok; }); it('should getProperty readonly from an input Element', function(){ var readonly1 = new Element('input', { type: 'text' }); readonly1.readOnly = 'readonly'; - expect(readonly1.getProperty('readonly')).toBeTruthy(); + expect(readonly1.getProperty('readonly')).to.be.ok; var readonly2 = new Element('input', { type: 'text' }); readonly2.readOnly = true; - expect(readonly2.getProperty('readonly')).toBeTruthy(); + expect(readonly2.getProperty('readonly')).to.be.ok; var readonly3 = new Element('input', { type: 'text' }); readonly3.readOnly = false; - expect(readonly3.getProperty('readonly')).toBeFalsy(); + expect(readonly3.getProperty('readonly')).to.not.be.ok; }); }); @@ -1292,61 +1296,61 @@ describe('Element.setProperty', function(){ it('should setProperty from an Element', function(){ var anchor1 = new Element('a').setProperty('href', 'http://mootools.net/'); - expect(anchor1.getProperty('href')).toEqual('http://mootools.net/'); + expect(anchor1.getProperty('href')).to.equal('http://mootools.net/'); var anchor2 = new Element('a').setProperty('href', '#someLink'); - expect(anchor2.getProperty('href')).toEqual('#someLink'); + expect(anchor2.getProperty('href')).to.equal('#someLink'); }); it('should setProperty type of an input Element', function(){ var input1 = new Element('input').setProperty('type', 'text'); - expect(input1.getProperty('type')).toEqual('text'); + expect(input1.getProperty('type')).to.equal('text'); var input2 = new Element('input').setProperty('type', 'checkbox'); - expect(input2.getProperty('type')).toEqual('checkbox'); + expect(input2.getProperty('type')).to.equal('checkbox'); }); it('should setProperty checked from an input Element', function(){ var checked1 = new Element('input', { type: 'checkbox' }).setProperty('checked', 'checked'); - expect(checked1.getProperty('checked')).toBeTruthy(); + expect(checked1.getProperty('checked')).to.be.ok; var checked2 = new Element('input', { type: 'checkbox' }).setProperty('checked', true); - expect(checked2.getProperty('checked')).toBeTruthy(); + expect(checked2.getProperty('checked')).to.be.ok; var checked3 = new Element('input', { type: 'checkbox' }).setProperty('checked', false); - expect(checked3.getProperty('checked')).toBeFalsy(); + expect(checked3.getProperty('checked')).to.not.be.ok; }); it('should setProperty disabled of an input Element', function(){ var disabled1 = new Element('input', { type: 'text' }).setProperty('disabled', 'disabled'); - expect(disabled1.getProperty('disabled')).toBeTruthy(); + expect(disabled1.getProperty('disabled')).to.be.ok; var disabled2 = new Element('input', { type: 'text' }).setProperty('disabled', true); - expect(disabled2.getProperty('disabled')).toBeTruthy(); + expect(disabled2.getProperty('disabled')).to.be.ok; var disabled3 = new Element('input', { type: 'text' }).setProperty('disabled', false); - expect(disabled3.getProperty('disabled')).toBeFalsy(); + expect(disabled3.getProperty('disabled')).to.not.be.ok; }); it('should setProperty readonly of an input Element', function(){ var readonly1 = new Element('input', { type: 'text' }).setProperty('readonly', 'readonly'); - expect(readonly1.getProperty('readonly')).toBeTruthy(); + expect(readonly1.getProperty('readonly')).to.be.ok; var readonly2 = new Element('input', { type: 'text' }).setProperty('readonly', true); - expect(readonly2.getProperty('readonly')).toBeTruthy(); + expect(readonly2.getProperty('readonly')).to.be.ok; var readonly3 = new Element('input', { type: 'text' }).setProperty('readonly', false); - expect(readonly3.getProperty('readonly')).toBeFalsy(); + expect(readonly3.getProperty('readonly')).to.not.be.ok; }); it('should setProperty defaultValue of an input Element', function(){ var form = new Element('form'); var defaultValue = new Element('input', {'type': 'text', 'value': '321'}); - expect(defaultValue.getProperty('value')).toEqual('321'); + expect(defaultValue.getProperty('value')).to.equal('321'); defaultValue.setProperty('defaultValue', '123'); form.grab(defaultValue); form.reset(); - expect(defaultValue.getProperty('value')).toEqual('123'); + expect(defaultValue.getProperty('value')).to.equal('123'); }); }); @@ -1356,7 +1360,7 @@ describe('Element.getProperties', function(){ it('should return an object associate with the properties passed', function(){ var readonly = new Element('input', { type: 'text', readonly: 'readonly' }); var props = readonly.getProperties('type', 'readonly'); - expect(props).toEqual({ type: 'text', readonly: true }); + expect(props).to.deep.equal({ type: 'text', readonly: true }); }); }); @@ -1366,7 +1370,7 @@ describe('Element.setProperties', function(){ it('should set each property to the Element', function(){ var readonly = new Element('input').setProperties({ type: 'text', readonly: 'readonly' }); var props = readonly.getProperties('type', 'readonly'); - expect(props).toEqual({ type: 'text', readonly: true }); + expect(props).to.deep.equal({ type: 'text', readonly: true }); }); }); @@ -1376,7 +1380,7 @@ describe('Element.removeProperties', function(){ it('should remove each property from the Element', function(){ var anchor = new Element('a', {href: '#', title: 'title', rel: 'left'}); anchor.removeProperties('title', 'rel'); - expect(anchor.getProperties('href', 'title', 'rel')).toEqual({ href: '#', title: null, rel: null }); + expect(anchor.getProperties('href', 'title', 'rel')).to.deep.equal({ href: '#', title: null, rel: null }); }); }); @@ -1387,16 +1391,16 @@ describe('Element.getPrevious', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[1].getPrevious()).toEqual(children[0]); - expect(children[0].getPrevious()).toBeNull(); + expect(children[1].getPrevious()).to.equal(children[0]); + expect(children[0].getPrevious()).to.equal(null); }); it('should return the previous Element that matches, otherwise null', function(){ var container = new Element('div'); var children = [new Element('a'), new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[1].getPrevious('a')).toEqual(children[0]); - expect(children[1].getPrevious('span')).toBeNull(); + expect(children[1].getPrevious('a')).to.equal(children[0]); + expect(children[1].getPrevious('span')).to.equal(null); }); }); @@ -1407,16 +1411,16 @@ describe('Element.getAllPrevious', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[2].getAllPrevious()).toEqual(new Elements([children[1], children[0]])); - expect(children[0].getAllPrevious()).toEqual(new Elements([])); + expect(children[2].getAllPrevious()).to.deep.equal(new Elements([children[1], children[0]])); + expect(children[0].getAllPrevious()).to.deep.equal(new Elements([])); }); it('should return all the previous Elements that match, otherwise an empty array', function(){ var container = new Element('div'); var children = [new Element('a'), new Element('div'), new Element('a'), new Element('div')]; container.adopt(children); - expect(children[3].getAllPrevious('a')).toEqual(new Elements([children[2], children[0]])); - expect(children[1].getAllPrevious('span')).toEqual(new Elements([])); + expect(children[3].getAllPrevious('a')).to.deep.equal(new Elements([children[2], children[0]])); + expect(children[1].getAllPrevious('span')).to.deep.equal(new Elements([])); }); }); @@ -1427,16 +1431,16 @@ describe('Element.getNext', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[1].getNext()).toEqual(children[2]); - expect(children[2].getNext()).toBeNull(); + expect(children[1].getNext()).to.equal(children[2]); + expect(children[2].getNext()).to.equal(null); }); it('should return the previous Element that matches, otherwise null', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div'), new Element('a')]; container.adopt(children); - expect(children[1].getNext('a')).toEqual(children[3]); - expect(children[1].getNext('span')).toBeNull(); + expect(children[1].getNext('a')).to.equal(children[3]); + expect(children[1].getNext('span')).to.equal(null); }); }); @@ -1447,16 +1451,16 @@ describe('Element.getAllNext', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[0].getAllNext()).toEqual(new Elements(children.slice(1))); - expect(children[2].getAllNext()).toEqual(new Elements([])); + expect(children[0].getAllNext()).to.deep.equal(new Elements(children.slice(1))); + expect(children[2].getAllNext()).to.deep.equal(new Elements([])); }); it('should return all the next Elements that match, otherwise an empty array', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('a'), new Element('div'), new Element('a')]; container.adopt(children); - expect(children[0].getAllNext('a')).toEqual(new Elements([children[1], children[3]])); - expect(children[0].getAllNext('span')).toEqual(new Elements([])); + expect(children[0].getAllNext('a')).to.deep.equal(new Elements([children[1], children[3]])); + expect(children[0].getAllNext('span')).to.deep.equal(new Elements([])); }); }); @@ -1467,8 +1471,8 @@ describe('Element.getFirst', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('a'), new Element('div')]; container.adopt(children); - expect(container.getFirst()).toEqual(children[0]); - expect(children[0].getFirst()).toBeNull(); + expect(container.getFirst()).to.equal(children[0]); + expect(children[0].getFirst()).to.equal(null); }); }); @@ -1479,16 +1483,16 @@ describe('Element.getLast', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('a'), new Element('div')]; container.adopt(children); - expect(container.getLast()).toEqual(children[2]); - expect(children[0].getLast()).toBeNull(); + expect(container.getLast()).to.equal(children[2]); + expect(children[0].getLast()).to.equal(null); }); it('should return the last Element in the Element that matches, otherwise null', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('a'), new Element('div'), new Element('a')]; container.adopt(children); - expect(container.getLast('a')).toEqual(children[3]); - expect(container.getLast('span')).toBeNull(); + expect(container.getLast('a')).to.equal(children[3]); + expect(container.getLast('span')).to.equal(null); }); }); @@ -1499,16 +1503,16 @@ describe('Element.getParent', function(){ var container = new Element('p'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(children[1].getParent()).toEqual(container); - expect(container.getParent()).toBeNull(); + expect(children[1].getParent()).to.equal(container); + expect(container.getParent()).to.equal(null); }); it('should return the parent of the Element that matches, otherwise null', function(){ var container = new Element('p'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(new Element('div').adopt(children)); - expect(children[1].getParent('p')).toEqual(container); - expect(children[1].getParent('table')).toBeNull(); + expect(children[1].getParent('p')).to.equal(container); + expect(children[1].getParent('table')).to.equal(null); }); }); @@ -1519,16 +1523,16 @@ describe('Element.getParents', function(){ var container = new Element('p'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(new Element('div').adopt(new Element('div').adopt(children))); - expect(children[1].getParents()).toEqual(new Elements([container.getFirst().getFirst(), container.getFirst(), container])); - expect(container.getParents()).toEqual(new Elements([])); + expect(children[1].getParents()).to.deep.equal(new Elements([container.getFirst().getFirst(), container.getFirst(), container])); + expect(container.getParents()).to.deep.equal(new Elements([])); }); it('should return the parents of the Element that match, otherwise returns an empty array', function(){ var container = new Element('p'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(new Element('div').adopt(new Element('div').adopt(children))); - expect(children[1].getParents('div')).toEqual(new Elements([container.getFirst().getFirst(), container.getFirst()])); - expect(children[1].getParents('table')).toEqual(new Elements([])); + expect(children[1].getParents('div')).to.deep.equal(new Elements([container.getFirst().getFirst(), container.getFirst()])); + expect(children[1].getParents('table')).to.deep.equal(new Elements([])); }); }); @@ -1539,16 +1543,16 @@ describe('Element.getChildren', function(){ var container = new Element('div'); var children = [new Element('div'), new Element('div'), new Element('div')]; container.adopt(children); - expect(container.getChildren()).toEqual(new Elements(children)); - expect(children[0].getChildren()).toEqual(new Elements([])); + expect(container.getChildren()).to.deep.equal(new Elements(children)); + expect(children[0].getChildren()).to.deep.equal(new Elements([])); }); it("should return the Element's children that match, otherwise returns an empty array", function(){ var container = new Element('div'); var children = [new Element('div'), new Element('a'), new Element('a')]; container.adopt(children); - expect(container.getChildren('a')).toEqual(new Elements([children[1], children[2]])); - expect(container.getChildren('span')).toEqual(new Elements([])); + expect(container.getChildren('a')).to.deep.equal(new Elements([children[1], children[2]])); + expect(container.getChildren('span')).to.deep.equal(new Elements([])); }); }); @@ -1569,34 +1573,34 @@ describe('Element.hasChild', function(){ //<1.3compat> it("should return true if the Element is a child or grandchild", function(){ - expect(Local.container.hasChild(Local.children[0])).toBeTruthy(); - expect(Local.container.hasChild(Local.children[2])).toBeTruthy(); - expect(Local.container.hasChild(Local.grandchild)).toBeTruthy(); + expect(Local.container.hasChild(Local.children[0])).to.equal(true); + expect(Local.container.hasChild(Local.children[2])).to.equal(true); + expect(Local.container.hasChild(Local.grandchild)).to.equal(true); }); it("should return false if it's the Element itself", function(){ - expect(Local.container.hasChild(Local.container)).toBeFalsy(); + expect(Local.container.hasChild(Local.container)).to.equal(false); }); it("should return false if the Element is the parent or a sibling", function(){ - expect(Local.children[2].hasChild(Local.container)).toBeFalsy(); - expect(Local.children[2].hasChild(Local.children[1])).toBeFalsy(); + expect(Local.children[2].hasChild(Local.container)).to.equal(false); + expect(Local.children[2].hasChild(Local.children[1])).to.equal(false); }); // it("should return true if the Element is a child or grandchild", function(){ - expect(Local.container.contains(Local.children[0])).toBeTruthy(); - expect(Local.container.contains(Local.children[2])).toBeTruthy(); - expect(Local.container.contains(Local.grandchild)).toBeTruthy(); + expect(Local.container.contains(Local.children[0])).to.equal(true); + expect(Local.container.contains(Local.children[2])).to.equal(true); + expect(Local.container.contains(Local.grandchild)).to.equal(true); }); it("should return true if it's the Element itself", function(){ - expect(Local.container.contains(Local.container)).toBeTruthy(); + expect(Local.container.contains(Local.container)).to.equal(true); }); it("should return false if the Element is the parent or a sibling", function(){ - expect(Local.children[2].contains(Local.container)).toBeFalsy(); - expect(Local.children[2].contains(Local.children[1])).toBeFalsy(); + expect(Local.children[2].contains(Local.container)).to.equal(false); + expect(Local.children[2].contains(Local.children[1])).to.equal(false); }); }); @@ -1614,8 +1618,8 @@ describe('Elements.extend', function(){ var container = new Element('div').adopt(items); container.getElements('span').extend(container.getElements('p')); - expect($$(items)).toEqual(container.getElements('*')); - expect(items.length).toEqual(4); + expect($$(items)).to.deep.equal(container.getElements('*')); + expect(items.length).to.equal(4); }); // @@ -1629,8 +1633,8 @@ describe('Elements.extend', function(){ var container = new Element('div').adopt(items); container.getElements('span').append(container.getElements('p')); - expect(new Elements(items)).toEqual(container.getElements('*')); - expect(items.length).toEqual(4); + expect(new Elements(items)).to.deep.equal(container.getElements('*')); + expect(items.length).to.equal(4); }); }); @@ -1641,17 +1645,17 @@ describe('document.id', function(){ var element = new Element('div#id\\.part.class').inject(document.body); var found = document.id('id.part'); - expect(found).toBe(element); - expect(found.id).toBe('id.part'); - expect(found.className).toBe('class'); + expect(found).to.equal(element); + expect(found.id).to.equal('id.part'); + expect(found.className).to.equal('class'); element.destroy(); element = new Element('div#id\\#part').inject(document.body); found = document.id('id#part'); - expect(found).toBe(element); - expect(found.id).toBe('id#part'); + expect(found).to.equal(element); + expect(found.id).to.equal('id#part'); }); }); @@ -1662,8 +1666,8 @@ describe('Element.getElementById', function(){ var inner = new Element('div#id\\.part'); var outer = new Element('div').adopt(inner); - expect(outer.getElementById('id.part')).toBe(inner); - expect(inner.id).toBe('id.part'); + expect(outer.getElementById('id.part')).to.equal(inner); + expect(inner.id).to.equal('id.part'); }); }); @@ -1675,10 +1679,10 @@ describe('Element.removeProperty', function(){ readonly.removeProperty('readonly'); readonly.removeProperty('maxlength'); var props = readonly.getProperties('type', 'readonly'); - expect(props).toEqual({type: 'text', readonly: false}); + expect(props).to.deep.equal({type: 'text', readonly: false}); var maxlength = readonly.getProperty('maxlength'); - expect(!maxlength || maxlength == 2147483647).toBeTruthy(); // ie6/7 Bug + expect(!maxlength || maxlength == 2147483647).to.be.ok; // ie6/7 Bug }); }); @@ -1697,7 +1701,7 @@ describe('Element.toQueryString', function(){ '' + '' }); - expect(form.toQueryString()).toEqual('input=checked&select%5B%5D=saab&select%5B%5D=opel&textarea=textarea-value'); + expect(form.toQueryString()).to.equal('input=checked&select%5B%5D=saab&select%5B%5D=opel&textarea=textarea-value'); }); it("should return a query string containing even empty values, single select must have a selected option", function(){ @@ -1712,8 +1716,8 @@ describe('Element.toQueryString', function(){ ), new Element('textarea', {name: 'textarea', value: ''}) ); - expect(form.toQueryString()).toEqual('input=&select%5B%5D=&textarea='); - expect(form.getElementsByTagName('select')[0].selectedIndex).toEqual(0); + expect(form.toQueryString()).to.equal('input=&select%5B%5D=&textarea='); + expect(form.getElementsByTagName('select')[0].selectedIndex).to.equal(0); }); }); @@ -1742,7 +1746,7 @@ describe('Element.clone', function(){ '' + ''); - expect(div.clone().getElementsByTagName('param').length).toBeGreaterThan(0); + expect(div.clone().getElementsByTagName('param').length).to.be.greaterThan(0); div = new Element('div').set('html', '
' + '' + @@ -1754,18 +1758,18 @@ describe('Element.clone', function(){ '' + '
'); - expect(div.clone().getElementsByTagName('param').length).toBeGreaterThan(0); + expect(div.clone().getElementsByTagName('param').length).to.be.greaterThan(0); }); it('should set the ID of the cloned element and then fetch it with document.id', function(){ var cloneMe = new Element('div', {id: 'cloneMe', text: 'cloneMe'}).inject(document.body); var cloned = $('cloneMe').clone(); - expect(cloned.get('id')).toEqual(null); + expect(cloned.get('id')).to.equal(null); cloned.set('id', 'sauce').inject(cloneMe.parentNode); - expect(cloned.get('id')).toEqual('sauce'); + expect(cloned.get('id')).to.equal('sauce'); var sauceHTML = new Element('div').adopt($('sauce')).get('html'); var cloneHTML = new Element('div').adopt(cloned).get('html'); - expect(sauceHTML).toEqual(cloneHTML); + expect(sauceHTML).to.equal(cloneHTML); cloneMe.destroy(); cloned.destroy(); }); @@ -1782,9 +1786,9 @@ describe('Elements implement order', function(){ anchor ); - expect(element.getLast()).toBe(anchor); + expect(element.getLast()).to.equal(anchor); - expect(new Elements([element, anchor]).getLast()).toBe(anchor); + expect(new Elements([element, anchor]).getLast()).to.equal(anchor); }); }); @@ -1801,11 +1805,11 @@ describe('Element traversal', function(){ var span = div.getElement('span'); var anchor = span.getElement('a'); - expect(anchor.getParent('div, span')).toBe(div); - expect(anchor.getParent('span, div')).toBe(span); + expect(anchor.getParent('div, span')).to.equal(div); + expect(anchor.getParent('span, div')).to.equal(span); - expect(anchor.getParent('tagname, div')).toBe(div); - expect(anchor.getParent('div > span')).toBe(span); + expect(anchor.getParent('tagname, div')).to.equal(div); + expect(anchor.getParent('div > span')).to.equal(span); }); }); @@ -1820,15 +1824,15 @@ describe('Elements.prototype.erase', function(){ var altered = element.getChildren().erase(original[1]); it('should decrease the length of the collection', function(){ - expect(altered.length).toEqual(2); + expect(altered.length).to.equal(2); }); it('should remove an element from the collection', function(){ - expect(altered[1]).toEqual(original[2]); + expect(altered[1]).to.equal(original[2]); }); it('should remove the last element from the collection', function(){ - expect(altered[2]).toEqual(undefined); + expect(altered[2]).to.equal(undefined); }); }); @@ -1838,12 +1842,12 @@ describe('Element.set("html")', function(){ it("should set the html of a tr Element, even when it has no parentNode", function(){ var html = 'cell 1cell 2'; var tr = new Element('tr'); - expect(tr.parentNode).toEqual(null); + expect(tr.parentNode).to.equal(null); // In IE using appendChild like in set('html') sets the parentNode to a documentFragment tr.set('html', html).inject(new Element('tbody').inject(new Element('table'))); - expect(tr.get('html').toLowerCase().replace(/>\s+<')).toEqual(html); - expect(tr.getChildren().length).toEqual(2); - expect(tr.getFirst().className).toEqual('cell c'); + expect(tr.get('html').toLowerCase().replace(/>\s+<')).to.equal(html); + expect(tr.getChildren().length).to.equal(2); + expect(tr.getFirst().className).to.equal('cell c'); }); it("should set the html of a style Element", function(){ @@ -1873,13 +1877,13 @@ describe('Element.set("html")', function(){ } styleElement.set('html', innerStyleA); - expect(getStyles()).toEqual(fixString(innerStyleA)); + expect(getStyles()).to.equal(fixString(innerStyleA)); styleElement.erase('html'); - expect(getStyles()).toEqual(''); + expect(getStyles()).to.equal(''); styleElement.set('html', innerStyleB); - expect(getStyles()).toEqual(fixString(innerStyleB)); + expect(getStyles()).to.equal(fixString(innerStyleB)); styleElement.destroy(); }); @@ -1898,11 +1902,11 @@ describe('Element.set("html")', function(){ ].join(''); styleElement.set('text', definition); var returned = styleElement.get('text').toLowerCase(); - expect(returned.indexOf('position: absolute')).not.toEqual(-1); - expect(returned.indexOf('width: 200px')).not.toEqual(-1); - expect(returned.indexOf('height: 200px')).not.toEqual(-1); - expect(returned.indexOf('left: 10%')).not.toEqual(-1); - expect(returned.indexOf('background: red')).not.toEqual(-1); + expect(returned.indexOf('position: absolute')).to.not.equal(-1); + expect(returned.indexOf('width: 200px')).to.not.equal(-1); + expect(returned.indexOf('height: 200px')).to.not.equal(-1); + expect(returned.indexOf('left: 10%')).to.not.equal(-1); + expect(returned.indexOf('background: red')).to.not.equal(-1); styleElement.destroy(); }); @@ -1913,8 +1917,8 @@ describe('Elements.empty', function(){ it('should empty the Elements collection', function(){ var list = $$('div').empty(); - expect(list.length).toEqual(0); - expect(list[0]).toBe(undefined); + expect(list.length).to.equal(0); + expect(list[0]).to.equal(undefined); }); }); @@ -1934,8 +1938,8 @@ describe('Elements.append', function(){ var appended = list.append(p); - expect(appended).toBe(list); - expect(appended).toEqual(new Elements([list[0], list[1], p[0], p[1]])); + expect(appended).to.equal(list); + expect(appended).to.deep.equal(new Elements([list[0], list[1], p[0], p[1]])); }); }); @@ -1955,10 +1959,10 @@ describe('Elements.concat', function(){ var concatenated = list.concat(p[0], p[1]); - expect(concatenated).not.toBe(list); - expect(concatenated).toEqual(new Elements([list[0], list[1], p[0], p[1]])); + expect(concatenated).to.not.equal(list); + expect(concatenated).to.deep.equal(new Elements([list[0], list[1], p[0], p[1]])); - expect(typeOf(concatenated)).toBe('elements'); + expect(typeOf(concatenated)).to.equal('elements'); }); }); @@ -1975,7 +1979,7 @@ describe('Element.getElement', function(){ div.adopt(p); var element = div.getElement(); - expect(element).toBe(null); + expect(element).to.equal(null); }); }); @@ -1992,11 +1996,11 @@ describe('Element.getElements', function(){ div.adopt(p); var elements = div.getElements(); - expect(elements.length).toBe(0); + expect(elements.length).to.equal(0); }); it('should return an empty collection if called on document.body', function(){ - expect($(document.body).getElements()).toEqual(new Elements); + expect($(document.body).getElements()).to.deep.equal(new Elements); }); }); @@ -2007,9 +2011,9 @@ describe('Element.getFirst', function(){ var container = new Element('div'); var children = [new Element('div').adopt(new Element('a')), new Element('a'), new Element('div')]; container.adopt(children); - expect(container.getFirst('div')).toBe(children[0]); - expect(container.getFirst('a')).toBe(children[1]); - expect(container.getFirst('span')).toBeNull(); + expect(container.getFirst('div')).to.equal(children[0]); + expect(container.getFirst('a')).to.equal(children[1]); + expect(container.getFirst('span')).to.equal(null); }); }); @@ -2019,9 +2023,9 @@ describe('Element.getLast', function(){ var container = new Element('div'); var children = [new Element('div').adopt(new Element('a')), new Element('a'), new Element('div')]; container.adopt(children); - expect(container.getLast('div')).toBe(children[2]); - expect(container.getLast('a')).toBe(children[1]); - expect(container.getLast('span')).toBeNull(); + expect(container.getLast('div')).to.equal(children[2]); + expect(container.getLast('a')).to.equal(children[1]); + expect(container.getLast('span')).to.equal(null); }); }); @@ -2037,12 +2041,12 @@ describe('Elements.unshift', function(){ length = collection.length; collection.unshift('someRandomValue'); - expect(collection.length).toBe(length); + expect(collection.length).to.equal(length); collection.unshift(new Element('p'), new Element('span')); - expect(collection.length).toBe(length + 2); - expect(collection.filter('p').length).toBe(2); - expect(collection.filter('span').length).toBe(2); + expect(collection.length).to.equal(length + 2); + expect(collection.filter('p').length).to.equal(2); + expect(collection.filter('span').length).to.equal(2); }); }); @@ -2052,43 +2056,43 @@ describe('Element.getProperty', function(){ it('should get the attrubte of a form when the form has an input with as ID the attribute name', function(){ var div = new Element('div'); div.innerHTML = '
'; - expect($(div.firstChild).getProperty('action')).toEqual('s'); + expect($(div.firstChild).getProperty('action')).to.equal('s'); }); it('should ignore expandos', function(){ var div = new Element('div'); - expect(div.getProperty('inject')).toBeNull(); + expect(div.getProperty('inject')).to.equal(null); }); it('should work in collaboration with setProperty', function(){ var div = new Element('div', {random: 'attribute'}); - expect(div.getProperty('random')).toEqual('attribute'); + expect(div.getProperty('random')).to.equal('attribute'); }); it('should get custom attributes in html', function(){ var div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-load')).toEqual('typical'); + expect(div.get('data-load')).to.equal('typical'); div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-custom')).toEqual(''); + expect(div.get('data-custom')).to.equal(''); div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-custom')).toEqual('nested'); + expect(div.get('data-custom')).to.equal('nested'); div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-custom')).toEqual(null); + expect(div.get('data-custom')).to.equal(null); div = new Element('div', {html: 'href'}).getFirst(); - expect(div.get('data-custom')).toEqual('singular'); + expect(div.get('data-custom')).to.equal('singular'); div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-custom')).toEqual('evil attribute values'); + expect(div.get('data-custom')).to.equal('evil attribute values'); div = new Element('div', {html: '
'}).getFirst(); - expect(div.get('data-custom')).toEqual('aggrevated evil attribute values'); + expect(div.get('data-custom')).to.equal('aggrevated evil attribute values'); div = new Element('div', {html: ' data-custom="singular"'}).getFirst(); - expect(div.get('data-custom')).toEqual(null); + expect(div.get('data-custom')).to.equal(null); }); }); @@ -2099,12 +2103,12 @@ describe('Element.set', function(){ it('should return `null` when the value of a input element is set to `undefined`', function(){ var value; - expect(new Element('input', {value: value}).get('value')).toEqual(''); + expect(new Element('input', {value: value}).get('value')).to.equal(''); }); it('should set a falsey value and not an empty string', function(){ - expect(new Element('input', {value: false}).get('value')).toEqual('false'); - expect(new Element('input', {value: 0}).get('value')).toEqual('0'); + expect(new Element('input', {value: false}).get('value')).to.equal('false'); + expect(new Element('input', {value: 0}).get('value')).to.equal('0'); }); it('should set the selected option for a select element to matching string w/o falsy matches', function(){ @@ -2114,7 +2118,7 @@ describe('Element.set', function(){ \ \ '); - expect(form.getElement('select').set('value', 0).get('value')).toEqual('0'); + expect(form.getElement('select').set('value', 0).get('value')).to.equal('0'); }); }); @@ -2122,7 +2126,7 @@ describe('Element.set', function(){ describe('type', function(){ it('should set the type of a button', function(){ - expect(new Element('button', {type: 'button'}).get('type')).toEqual('button'); + expect(new Element('button', {type: 'button'}).get('type')).to.equal('button'); }); }); @@ -2131,7 +2135,7 @@ describe('Element.set', function(){ it('should call the toString() method of a passed object', function(){ var a = new Element('a').set('href', {toString: function(){ return '1'; }}); - expect(a.get('href')).toEqual('1'); + expect(a.get('href')).to.equal('1'); }); }); @@ -2143,12 +2147,12 @@ describe("Element.setProperty('type')", function(){ it('should keep the input value after setting a input field to another type (submit button)', function(){ var input = new Element('input', {value: 'myValue', type: 'text'}); input.setProperty('type', 'submit'); - expect(input.getProperty('value')).toEqual('myValue'); + expect(input.getProperty('value')).to.equal('myValue'); }); it('should set the right type and value of input fields when a input field is created with CSS selectors', function(){ var input = new Element('input[type="submit"]', {value: 'myValue'}); - expect(input.getProperty('value')).toEqual('myValue'); + expect(input.getProperty('value')).to.equal('myValue'); }); }); @@ -2159,7 +2163,7 @@ describe('Element.get', function(){ it('should get the value of a option element when it does not have the value attribute', function(){ var select = new Element('select').set('html', ''); - expect(select.getElement('option').get('value')).toEqual('s'); + expect(select.getElement('option').get('value')).to.equal('s'); }); it('should return the text of the selected option for a select element', function(){ @@ -2170,7 +2174,7 @@ describe('Element.get', function(){ \ \ '); - expect(form.getElement('select').get('value')).toEqual('value 3'); + expect(form.getElement('select').get('value')).to.equal('value 3'); }); it('should return the text of the selected option for a multiple select element', function(){ @@ -2181,7 +2185,7 @@ describe('Element.get', function(){ \ \ '); - expect(form.getElement('select').get('value')).toEqual('value 2'); + expect(form.getElement('select').get('value')).to.equal('value 2'); }); it('should return the text of the first option of aselect element', function(){ @@ -2190,7 +2194,7 @@ describe('Element.get', function(){ \ \ '); - expect(form.getElement('select').get('value')).toEqual('value 1'); + expect(form.getElement('select').get('value')).to.equal('value 1'); }); it('should return value of a select element', function(){ @@ -2199,7 +2203,7 @@ describe('Element.get', function(){ \ \ '); - expect(form.getElement('select').get('value')).toEqual('two'); + expect(form.getElement('select').get('value')).to.equal('two'); }); }); @@ -2209,7 +2213,7 @@ describe('Element.get', function(){ it('should return the original text with `text-transform: uppercase`', function(){ var div = new Element('div', {html: '
text
'}); div.inject(document.body); - expect($(div.firstChild).get('text')).toEqual('text'); + expect($(div.firstChild).get('text')).to.equal('text'); div.destroy(); }); @@ -2222,8 +2226,8 @@ describe('tabIndex', function(){ it('should get and set the correct tabIndex', function(){ var div = document.createElement('div'); div.innerHTML = ''; - expect($(div.firstChild).get('tabindex')).toEqual(2); - expect($(div.firstChild).set('tabindex', 3).get('tabindex')).toEqual(3); + expect($(div.firstChild).get('tabindex')).to.equal(2); + expect($(div.firstChild).set('tabindex', 3).get('tabindex')).to.equal(3); }); }); @@ -2237,16 +2241,16 @@ if (document.createElement('video').canPlayType){ video = div.getElement('video'); if ('loop' in video){ - expect(video.getProperty('loop')).toBe(true); - expect(video.setProperty('loop', false).getProperty('loop')).toBe(false); + expect(video.getProperty('loop')).to.equal(true); + expect(video.setProperty('loop', false).getProperty('loop')).to.equal(false); } - expect(video.getProperty('controls')).toBe(true); - expect(video.setProperty('controls', false).getProperty('controls')).toBe(false); - expect(video.getProperty('autoplay')).toBe(true); - expect(video.setProperty('autoplay', false).getProperty('autoplay')).toBe(false); + expect(video.getProperty('controls')).to.equal(true); + expect(video.setProperty('controls', false).getProperty('controls')).to.equal(false); + expect(video.getProperty('autoplay')).to.equal(true); + expect(video.setProperty('autoplay', false).getProperty('autoplay')).to.equal(false); }catch(O_o){ if(O_o.message.indexOf('Not implemented') == -1){ - expect(O_o.message + " : "+O_o).toBe("") + expect(O_o.message + " : "+O_o).to.equal('') } } }); @@ -2259,7 +2263,7 @@ describe("Element.set('html')", function(){ describe('HTML5 tags', function(){ it('should create childNodes for html5 tags', function(){ - expect(new Element('div', {html: '

Tuuls

!
'}).childNodes.length).toEqual(3); + expect(new Element('div', {html: '

Tuuls

!
'}).childNodes.length).to.equal(3); }); }); @@ -2267,7 +2271,7 @@ describe("Element.set('html')", function(){ describe('Numbers', function(){ it('should set a number (so no string) as html', function(){ - expect(new Element('div', {html: 20}).innerHTML).toEqual('20'); + expect(new Element('div', {html: 20}).innerHTML).to.equal('20'); }); }); @@ -2275,7 +2279,7 @@ describe("Element.set('html')", function(){ describe('Arrays', function(){ it('should allow an Array as input, the text is concatenated', function(){ - expect(new Element('div', {html: ['moo', 'rocks', 'your', 'socks', 1]}).innerHTML).toEqual('moorocksyoursocks1'); + expect(new Element('div', {html: ['moo', 'rocks', 'your', 'socks', 1]}).innerHTML).to.equal('moorocksyoursocks1'); }); }); @@ -2285,7 +2289,7 @@ describe("Element.set('html')", function(){ describe("Element.erase('html')", function(){ it('should empty the html inside an element', function(){ - expect(new Element('div', {html: '

foo bar

'}).erase('html').innerHTML).toEqual(''); + expect(new Element('div', {html: '

foo bar

'}).erase('html').innerHTML).to.equal(''); }); }); @@ -2327,24 +2331,24 @@ describe('Element.erase', function(){ it('should erase the class of an Element', function(){ subject.set('class', 'test'); subject.erase('class'); - expect(subject.get('class')).toEqual(null); + expect(subject.get('class')).to.equal(null); }); it('should erase the id of an Element', function(){ subject.set('id', 'test'); subject.erase('id'); - expect(subject.get('id')).toEqual(null); + expect(subject.get('id')).to.equal(null); }); it('should erase the random attribute of an Element', function(){ subject.set('random', 'test'); subject.erase('random'); - expect(subject.get('random')).toEqual(null); + expect(subject.get('random')).to.equal(null); }); it('should erase the value attribute of a textarea', function(){ textarea.erase('value'); - expect(textarea.get('value')).toEqual(''); + expect(textarea.get('value')).to.equal(''); }); }); @@ -2382,10 +2386,10 @@ describe('Element.appendHTML', function(){ var children = check.getElements('span'); - expect(children.length).toBe(2); + expect(children.length).to.equal(2); children.each(function(child, i){ - expect(child.get('text')).toBe('HI!'); - expect(child.nextSibling.getAttribute('rel')).toBe('' + i); + expect(child.get('text')).to.equal('HI!'); + expect(child.nextSibling.getAttribute('rel')).to.equal('' + i); }); }); @@ -2395,10 +2399,10 @@ describe('Element.appendHTML', function(){ var children = check.getElements('span'); - expect(children.length).toBe(2); + expect(children.length).to.equal(2); children.each(function(child, i){ - expect(child.get('text')).toBe('HI!'); - expect(child.previousSibling.getAttribute('rel')).toBe('' + i); + expect(child.get('text')).to.equal('HI!'); + expect(child.previousSibling.getAttribute('rel')).to.equal('' + i); }); }); @@ -2408,12 +2412,12 @@ describe('Element.appendHTML', function(){ var children = check.getElements('span'); - expect(children.length).toBe(2); - expect(children.each(function(child, i){ - expect(child.get('text')).toBe('HI!'); - expect(child.parentNode.getAttribute('rel')).toBe('' + i); - expect(child.parentNode.get('text')).toBe('contentHI!'); - })); + expect(children.length).to.equal(2); + children.each(function(child, i){ + expect(child.get('text')).to.equal('HI!'); + expect(child.parentNode.getAttribute('rel')).to.equal('' + i); + expect(child.parentNode.get('text')).to.equal('contentHI!'); + }); }); it('should insert element on top', function(){ @@ -2422,11 +2426,11 @@ describe('Element.appendHTML', function(){ var children = check.getElements('span'); - expect(children.length).toBe(2); + expect(children.length).to.equal(2); children.each(function(child, i){ - expect(child.get('text')).toBe('HI!'); - expect(child.parentNode.getAttribute('rel')).toBe('' + i); - expect(child.parentNode.get('text')).toBe('HI!content'); + expect(child.get('text')).to.equal('HI!'); + expect(child.parentNode.getAttribute('rel')).to.equal('' + i); + expect(child.parentNode.get('text')).to.equal('HI!content'); }); }); @@ -2436,11 +2440,11 @@ describe('Element.appendHTML', function(){ var children = check.getElements('span'); - expect(children.length).toBe(2); + expect(children.length).to.equal(2); children.each(function(child, i){ - expect(child.get('text')).toBe('HI!'); - expect(child.parentNode.getAttribute('rel')).toBe('' + i); - expect(child.parentNode.get('text')).toBe('contentHI!'); + expect(child.get('text')).to.equal('HI!'); + expect(child.parentNode.getAttribute('rel')).to.equal('' + i); + expect(child.parentNode.get('text')).to.equal('contentHI!'); }); }); @@ -2458,7 +2462,7 @@ describe('IFrame', function(){ }); it('(async) should call onload', function(){ - expect(this.onComplete.called).toBe(true); + expect(this.onComplete.called).to.equal(true); }, 1000); afterEach(function(){ @@ -2472,10 +2476,10 @@ describe('new Element(expression)', function(){ it('should create a new div element', function(){ var div = new Element('div'); - expect(div.tagName.toLowerCase()).toEqual('div'); - expect(!div.className && div.className.length == 0).toBeTruthy(); - expect(!div.id && div.id.length == 0).toBeTruthy(); - expect(typeOf(div)).toEqual('element'); + expect(div.tagName.toLowerCase()).to.equal('div'); + expect(!div.className && div.className.length == 0).to.equal(true); + expect(!div.id && div.id.length == 0).to.equal(true); + expect(typeOf(div)).to.equal('element'); }); it('should create a new element with id and class', function(){ @@ -2484,24 +2488,24 @@ describe('new Element(expression)', function(){ 'class': 'test className' }); - expect(p.tagName.toLowerCase()).toEqual('p'); - expect(p.className).toEqual('test className'); + expect(p.tagName.toLowerCase()).to.equal('p'); + expect(p.className).to.equal('test className'); }); it('should create a new element with id and class from css expression', function(){ var p = new Element('p#myParagraph.test.className'); - expect(p.tagName.toLowerCase()).toEqual('p'); - expect(p.className).toEqual('test className'); + expect(p.tagName.toLowerCase()).to.equal('p'); + expect(p.className).to.equal('test className'); }); it('should create attributes from css expression', function(){ var input = new Element('input[type=text][readonly=true][value=Some Text]'); - expect(input.tagName.toLowerCase()).toEqual('input'); - expect(input.type).toEqual('text'); - expect(input.readOnly).toEqual(true); - expect(input.value).toEqual('Some Text'); + expect(input.tagName.toLowerCase()).to.equal('input'); + expect(input.type).to.equal('text'); + expect(input.readOnly).to.equal(true); + expect(input.value).to.equal('Some Text'); }); it('should overwrite ids and classes', function(){ @@ -2510,9 +2514,9 @@ describe('new Element(expression)', function(){ 'class': 'overwrittenClass' }); - expect(div.tagName.toLowerCase()).toEqual('div'); - expect(div.id).toEqual('myOverwrittenId'); - expect(div.className).toEqual('overwrittenClass'); + expect(div.tagName.toLowerCase()).to.equal('div'); + expect(div.id).to.equal('myOverwrittenId'); + expect(div.className).to.equal('overwrittenClass'); }); it('should overwrite attributes', function(){ @@ -2520,8 +2524,8 @@ describe('new Element(expression)', function(){ href: 'http://mootools.net/' }); - expect(a.tagName.toLowerCase()).toEqual('a'); - expect(a.href).toEqual('http://mootools.net/'); + expect(a.tagName.toLowerCase()).to.equal('a'); + expect(a.href).to.equal('http://mootools.net/'); }); it('should reset attributes and classes with empty string', function(){ @@ -2530,9 +2534,9 @@ describe('new Element(expression)', function(){ 'class': '' }); - expect(div.tagName.toLowerCase()).toEqual('div'); - expect(div.id).toEqual(''); - expect(div.className).toEqual(''); + expect(div.tagName.toLowerCase()).to.equal('div'); + expect(div.id).to.equal(''); + expect(div.className).to.equal(''); }); it('should not reset attributes and classes with null', function(){ @@ -2541,9 +2545,9 @@ describe('new Element(expression)', function(){ 'class': null }); - expect(div.tagName.toLowerCase()).toEqual('div'); - expect(div.id).toEqual('myDiv'); - expect(div.className).toEqual('myClass'); + expect(div.tagName.toLowerCase()).to.equal('div'); + expect(div.id).to.equal('myDiv'); + expect(div.className).to.equal('myClass'); }); it('should not reset attributes and classes with undefined', function(){ @@ -2552,28 +2556,28 @@ describe('new Element(expression)', function(){ 'class': undefined }); - expect(div.tagName.toLowerCase()).toEqual('div'); - expect(div.id).toEqual('myDiv'); - expect(div.className).toEqual('myClass'); + expect(div.tagName.toLowerCase()).to.equal('div'); + expect(div.id).to.equal('myDiv'); + expect(div.className).to.equal('myClass'); }); it('should fall back to a div tag', function(){ var someElement = new Element('#myId'); - expect(someElement.tagName.toLowerCase()).toEqual('div'); - expect(someElement.id).toEqual('myId'); + expect(someElement.tagName.toLowerCase()).to.equal('div'); + expect(someElement.id).to.equal('myId'); }); it('should allow zero (0) values', function(){ var table = new Element('table[cellpadding=0]'); - expect(table.tagName.toLowerCase()).toEqual('table'); - expect(table.cellPadding == 0).toBeTruthy(); + expect(table.tagName.toLowerCase()).to.equal('table'); + expect(table.cellPadding == 0).to.be.ok; }); it('should allow empty boolean attributes', function(){ var script = new Element('script[async]'); - expect(script.get('async')).toBeTruthy(); + expect(script.get('async')).to.be.ok; }); it('should allow false to be passed for checked', function(){ @@ -2582,7 +2586,7 @@ describe('new Element(expression)', function(){ checked: false }); - expect(input.checked).toEqual(false); + expect(input.checked).to.equal(false); }); }); @@ -2594,31 +2598,31 @@ describe('Element', function(){ it('should not fail for empty strings', function(){ var element = new Element('div'); element.addClass(''); - expect(element.className).toEqual(''); + expect(element.className).to.equal(''); }); it('should trim whitespaces', function(){ var element = new Element('div'); element.addClass(' bar '); - expect(element.className).toEqual('bar'); + expect(element.className).to.equal('bar'); }); it('should add multiple classes', function(){ var element = new Element('div'); element.addClass(' bar foo'); - expect(element.className).toEqual('bar foo'); + expect(element.className).to.equal('bar foo'); }); it('should add multiple equal classes', function(){ var element = new Element('div'); element.addClass('bar bar '); - expect(element.className).toEqual('bar'); + expect(element.className).to.equal('bar'); }); it('should add class with some newline', function(){ var element = new Element('div'); element.addClass('bar\nfoo'); - expect(element.className).toEqual('bar foo'); + expect(element.className).to.equal('bar foo'); }); }); @@ -2631,7 +2635,7 @@ describe('normalize value for new Element type == checkbox || radio', function() type: 'checkbox' }); input.set('checked', true); - expect(input.get('value')).toEqual('on'); + expect(input.get('value')).to.equal('on'); }); it('value of new created checkbox should be the specified in constructor', function() { var input = new Element('input', { @@ -2639,14 +2643,14 @@ describe('normalize value for new Element type == checkbox || radio', function() value: 'someValue' }); input.set('checked', true); - expect(input.get('value')).toEqual('someValue'); + expect(input.get('value')).to.equal('someValue'); }); it('value of new created radio button should be "on" if none specified', function() { var input = new Element('input', { type: 'radio' }); input.set('checked', true); - expect(input.get('value')).toEqual('on'); + expect(input.get('value')).to.equal('on'); }); it('value of new created radio should be the specified in constructor', function() { var input = new Element('input', { @@ -2654,6 +2658,6 @@ describe('normalize value for new Element type == checkbox || radio', function() value: 'someValue' }); input.set('checked', true); - expect(input.get('value')).toEqual('someValue'); + expect(input.get('value')).to.equal('someValue'); }); }); diff --git a/Specs/Fx/Fx.Morph.js b/Specs/Fx/Fx.Morph.js index e0a2c564..7cc9a490 100644 --- a/Specs/Fx/Fx.Morph.js +++ b/Specs/Fx/Fx.Morph.js @@ -54,8 +54,8 @@ describe('Fx.Morph', function(){ this.clock.tick(200); - expect(element.getStyle('height').toInt()).toEqual(50); - expect(element.getStyle('width').toInt()).toEqual(50); + expect(element.getStyle('height').toInt()).to.equal(50); + expect(element.getStyle('width').toInt()).to.equal(50); element.destroy(); }); @@ -68,7 +68,7 @@ describe('Fx.Morph', function(){ duration: 100 }); - expect(element.get('morph').options.duration).toEqual(100); + expect(element.get('morph').options.duration).to.equal(100); }); @@ -78,8 +78,8 @@ describe('Fx.Morph', function(){ this.clock.tick(1000); - expect(this.div.setStyle.calledWith('left', ['10%'])).toBe(true); - expect(this.div.setStyle.calledWith('left', ['50%'])).toBe(true); + expect(this.div.setStyle.calledWith('left', ['10%'])).to.equal(true); + expect(this.div.setStyle.calledWith('left', ['50%'])).to.equal(true); this.div.setStyle.restore(); }); @@ -96,8 +96,8 @@ describe('Fx.Morph', function(){ this.clock.tick(150); - expect(this.div.getStyle('top')).toEqual('100px'); - expect(this.div.getStyle('opacity')).toEqual(1); + expect(this.div.getStyle('top')).to.equal('100px'); + expect(this.div.getStyle('opacity')).to.equal(1); }); @@ -116,8 +116,8 @@ describe('Fx.Morph', function(){ this.clock.tick(150); - expect(this.div.getStyle('top')).toEqual('100px'); - expect(this.div.getStyle('opacity')).toEqual(1); + expect(this.div.getStyle('top')).to.equal('100px'); + expect(this.div.getStyle('opacity')).to.equal(1); }); diff --git a/Specs/Fx/Fx.Tween.js b/Specs/Fx/Fx.Tween.js index 63ee86eb..fc2b5419 100644 --- a/Specs/Fx/Fx.Tween.js +++ b/Specs/Fx/Fx.Tween.js @@ -33,7 +33,7 @@ describe('Fx.Tween', function(){ this.clock.tick(200); - expect(element.getStyle('height').toInt()).toEqual(50); + expect(element.getStyle('height').toInt()).to.equal(50); element.destroy(); }); @@ -51,7 +51,7 @@ describe('Fx.Tween', function(){ this.clock.tick(200); - expect(element.getStyle('width').toInt()).toEqual(50); + expect(element.getStyle('width').toInt()).to.equal(50); element.destroy(); }); @@ -70,7 +70,7 @@ describe('Fx.Tween', function(){ this.clock.tick(130); - expect(element.getStyle('opacity').toInt()).toEqual(1); + expect(element.getStyle('opacity').toInt()).to.equal(1); element.destroy(); }); @@ -96,9 +96,9 @@ describe('Fx.Tween', function(){ lastOpacity = element.getStyle('opacity'); lastVisibility = element.getStyle('visibility'); - expect(firstOpacity.toInt()).toEqual(0); - expect(lastOpacity.toInt()).toEqual(1); - expect(lastVisibility).toEqual('visible'); + expect(firstOpacity.toInt()).to.equal(0); + expect(lastOpacity.toInt()).to.equal(1); + expect(lastVisibility).to.equal('visible'); element.destroy(); }); @@ -116,7 +116,7 @@ describe('Fx.Tween', function(){ this.clock.tick(130); - expect(element.getStyle('opacity').toInt()).toEqual(0); + expect(element.getStyle('opacity').toInt()).to.equal(0); element.destroy(); }); @@ -129,7 +129,7 @@ describe('Fx.Tween', function(){ duration: 100 }); - expect(element.get('tween').options.duration).toEqual(100); + expect(element.get('tween').options.duration).to.equal(100); }); @@ -145,7 +145,7 @@ describe('Fx.Tween', function(){ this.clock.tick(40); - expect(['#fff', '#ffffff']).toContain(element.getStyle('background-color').toLowerCase()); + expect(['#fff', '#ffffff']).to.contain(element.getStyle('background-color').toLowerCase()); element.destroy(); }); @@ -156,19 +156,19 @@ describe('Fx.Tween', function(){ var element = new Element('div', {styles: {'visibility': 'visible'}}).inject(document.body); - expect(element.getStyles('opacity', 'visibility')).toEqual({opacity: 1, visibility: 'visible'}); + expect(element.getStyles('opacity', 'visibility')).to.deep.equal({opacity: 1, visibility: 'visible'}); element.fade(0.5); this.clock.tick(600); - expect(element.getStyles('opacity', 'visibility')).toEqual({opacity: 0.5, visibility: 'visible'}); + expect(element.getStyles('opacity', 'visibility')).to.deep.equal({opacity: 0.5, visibility: 'visible'}); element.fade(0); this.clock.tick(600); - expect(element.getStyles('opacity', 'visibility')).toEqual({opacity: 0, visibility: 'hidden'}); + expect(element.getStyles('opacity', 'visibility')).to.deep.equal({opacity: 0, visibility: 'hidden'}); element.fade(1); this.clock.tick(600); - expect(element.getStyles('opacity', 'visibility')).toEqual({opacity: 1, visibility: 'visible'}); + expect(element.getStyles('opacity', 'visibility')).to.deep.equal({opacity: 1, visibility: 'visible'}); element.destroy(); @@ -181,12 +181,12 @@ describe('Fx.Tween', function(){ var tween = element.get('tween'); - expect(tween.from[0].value).toEqual(1); - expect(tween.to[0].value).toEqual(0); + expect(tween.from[0].value).to.equal(1); + expect(tween.to[0].value).to.equal(0); this.clock.tick(1000); - expect(element.getStyle('opacity')).toEqual(0); + expect(element.getStyle('opacity')).to.equal(0); }); diff --git a/Specs/Fx/Fx.js b/Specs/Fx/Fx.js index f29e37f0..c3f84289 100644 --- a/Specs/Fx/Fx.js +++ b/Specs/Fx/Fx.js @@ -31,16 +31,16 @@ describe('Fx', function(){ onStart: onStart }); - expect(onStart.called).toBe(false); + expect(onStart.called).to.equal(false); fx.start(10, 20); this.clock.tick(100); - expect(onStart.called).toBe(true); - expect(onComplete.called).toBe(false); + expect(onStart.called).to.equal(true); + expect(onComplete.called).to.equal(false); this.clock.tick(1000); - expect(onComplete.called).toBe(true); + expect(onComplete.called).to.equal(true); }); }); @@ -57,11 +57,11 @@ describe('Fx', function(){ fx.start(); - expect(onCancel.called).toBe(false); + expect(onCancel.called).to.equal(false); fx.cancel(); - expect(onCancel.called).toBe(true); + expect(onCancel.called).to.equal(true); }); @@ -80,7 +80,7 @@ describe('Fx', function(){ this.clock.tick(2000); - expect(fx.foo).toEqual(10); + expect(fx.foo).to.equal(10); }); @@ -103,17 +103,17 @@ describe('Fx', function(){ fx.pause(); value = fx.foo; - expect(fx.foo).toBeGreaterThan(0); - expect(fx.foo).toBeLessThan(1); + expect(fx.foo).to.be.greaterThan(0); + expect(fx.foo).to.be.lessThan(1); this.clock.tick(1000); - expect(fx.foo).toEqual(value); + expect(fx.foo).to.equal(value); fx.resume(); this.clock.tick(2000); - expect(fx.foo).toEqual(1); + expect(fx.foo).to.equal(1); }); @@ -133,7 +133,7 @@ describe('Fx', function(){ this.clock.tick(1000); this.clock.tick(1000); - expect(counter).toEqual(2); + expect(counter).to.equal(2); }); it('should cancel the Fx after a new Fx:start with the link = cancel option', function(){ @@ -150,7 +150,7 @@ describe('Fx', function(){ this.clock.tick(1000); - expect(onCancel.called).toBe(true); + expect(onCancel.called).to.equal(true); }); @@ -172,16 +172,16 @@ describe('Fx', function(){ duration: 500 }).start(); - expect(fx.isPaused()).toEqual(false); + expect(fx.isPaused()).to.equal(false); this.clock.tick(300); fx.pause(); - expect(fx.isPaused()).toEqual(true); + expect(fx.isPaused()).to.equal(true); fx.resume(); this.clock.tick(600); - expect(fx.isPaused()).toEqual(false); + expect(fx.isPaused()).to.equal(false); }); }); diff --git a/Specs/Request/Request.HTML.js b/Specs/Request/Request.HTML.js index 790e03af..329c4b4f 100644 --- a/Specs/Request/Request.HTML.js +++ b/Specs/Request/Request.HTML.js @@ -33,17 +33,17 @@ describe('Request.HTML', function(){ this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); // checks arguments order - expect(this.spy.calledWith(request.response.tree, request.response.elements, request.response.html, request.response.javascript)).toBe(true); + expect(this.spy.calledWith(request.response.tree, request.response.elements, request.response.html, request.response.javascript)).to.equal(true); var onCompleteArgs = this.spy.args[0]; - expect(onCompleteArgs[0][0].nodeName).toEqual('IMG'); - expect(onCompleteArgs[0][1].nodeName).toEqual('DIV'); - expect(onCompleteArgs[1][2].nodeName).toEqual('SPAN'); - expect(onCompleteArgs[2]).toEqual('
res&ponsé
'); - expect(onCompleteArgs[3].trim()).toEqual('___SPEC___=5;'); - expect(___SPEC___).toEqual(5); + expect(onCompleteArgs[0][0].nodeName).to.equal('IMG'); + expect(onCompleteArgs[0][1].nodeName).to.equal('DIV'); + expect(onCompleteArgs[1][2].nodeName).to.equal('SPAN'); + expect(onCompleteArgs[2]).to.equal('
res&ponsé
'); + expect(onCompleteArgs[3].trim()).to.equal('___SPEC___=5;'); + expect(___SPEC___).to.equal(5); }); @@ -60,13 +60,13 @@ describe('Request.HTML', function(){ }); it('should create an ajax request and correctly generate the tree response from a tr', function(){ - expect(this.onComplete.called).toBe(true); + expect(this.onComplete.called).to.equal(true); var onCompleteArgs = this.onComplete.args[0]; - expect(onCompleteArgs[0][0].nodeName).toEqual('TR'); - expect(onCompleteArgs[1][1].nodeName).toEqual('TD'); - expect(onCompleteArgs[2]).toEqual('text'); + expect(onCompleteArgs[0][0].nodeName).to.equal('TR'); + expect(onCompleteArgs[1][1].nodeName).to.equal('TD'); + expect(onCompleteArgs[2]).to.equal('text'); }, 800); }); @@ -84,18 +84,18 @@ describe('Request.HTML', function(){ }); it('should create an ajax request and correctly generate the tree response from options', function(){ - expect(this.onComplete.called).toBe(true); + expect(this.onComplete.called).to.equal(true); var onCompleteArgs = this.onComplete.args[0]; - expect(onCompleteArgs[0].length).toEqual(3); - expect(onCompleteArgs[1].length).toEqual(3); - expect(onCompleteArgs[2]).toEqual(''); - expect(onCompleteArgs[3]).toBeFalsy(); + expect(onCompleteArgs[0].length).to.equal(3); + expect(onCompleteArgs[1].length).to.equal(3); + expect(onCompleteArgs[2]).to.equal(''); + expect(onCompleteArgs[3]).to.not.be.ok; var firstOption = onCompleteArgs[0][0]; - expect(firstOption.tagName).toEqual('OPTION'); - expect(firstOption.innerHTML).toEqual('1'); + expect(firstOption.tagName).to.equal('OPTION'); + expect(firstOption.innerHTML).to.equal('1'); }, 800); }); @@ -114,12 +114,12 @@ describe('Request.HTML', function(){ this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); var update = $('update'); - expect(update.getChildren().length).toEqual(1); - expect(update.getFirst().get('tag')).toEqual('span'); - expect(update.getFirst().get('text')).toEqual('text'); + expect(update.getChildren().length).to.equal(1); + expect(update.getFirst().get('tag')).to.equal('span'); + expect(update.getFirst().get('text')).to.equal('text'); update.dispose(); }); @@ -137,18 +137,18 @@ describe('Request.HTML', function(){ this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); var update = $('update'); - expect(update.getChildren().length).toEqual(2); - expect(update.getFirst().get('tag')).toEqual('div'); - expect(update.getFirst().get('text')).toEqual('some'); + expect(update.getChildren().length).to.equal(2); + expect(update.getFirst().get('tag')).to.equal('div'); + expect(update.getFirst().get('text')).to.equal('some'); var div = update.getFirst().getNext(); - expect(div.get('tag')).toEqual('div'); - expect(div.getFirst().get('tag')).toEqual('span'); - expect(div.getFirst().get('text')).toEqual('text'); - expect(div.getLast().get('tag')).toEqual('p'); - expect(div.getLast().get('text')).toEqual('paragraph'); + expect(div.get('tag')).to.equal('div'); + expect(div.getFirst().get('tag')).to.equal('span'); + expect(div.getFirst().get('text')).to.equal('text'); + expect(div.getLast().get('tag')).to.equal('p'); + expect(div.getLast().get('text')).to.equal('paragraph'); update.dispose(); }); @@ -165,12 +165,12 @@ describe('Request.HTML', function(){ }).send(); this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); var onCompleteArgs = this.spy.args[0]; - expect(onCompleteArgs[0].length).toEqual(1); - expect(onCompleteArgs[0][0].get('tag')).toEqual('a'); - expect(onCompleteArgs[0][0].get('text')).toEqual('aaa'); + expect(onCompleteArgs[0].length).to.equal(1); + expect(onCompleteArgs[0][0].get('tag')).to.equal('a'); + expect(onCompleteArgs[0][0].get('text')).to.equal('aaa'); }); @@ -188,12 +188,12 @@ describe('Request.HTML', function(){ }).send(); this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); var update = $('update'); - expect(update.getChildren().length).toEqual(1); - expect(update.getFirst().get('tag')).toEqual('a'); - expect(update.getFirst().get('text')).toEqual('a link'); + expect(update.getChildren().length).to.equal(1); + expect(update.getFirst().get('tag')).to.equal('a'); + expect(update.getFirst().get('text')).to.equal('a link'); update.dispose(); }); @@ -212,11 +212,11 @@ describe('Request.HTML', function(){ }).send(); this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); var update = $('update'); - expect(update.getChildren().length).toEqual(2); - expect(update.get('html').toLowerCase()).toEqual('
some
a link'); + expect(update.getChildren().length).to.equal(2); + expect(update.get('html').toLowerCase()).to.equal('
some
a link'); update.dispose(); }); @@ -233,17 +233,17 @@ describe('Request.HTML', function(){ onComplete: this.spy }).get('load'); - expect(instanceOf(request, Request.HTML)).toBeTruthy(); + expect(instanceOf(request, Request.HTML)).to.equal(true); element.load({ '__response': response, '__type': 'html' }); this.requests[0].respond(200, {'Content-Type': 'text/html'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); setTimeout(function(){ - expect(element.get('text')).toEqual('hello world!'); + expect(element.get('text')).to.equal('hello world!'); done(); }, 0); diff --git a/Specs/Request/Request.JSON.js b/Specs/Request/Request.JSON.js index 10b95b32..50cbd265 100644 --- a/Specs/Request/Request.JSON.js +++ b/Specs/Request/Request.JSON.js @@ -34,10 +34,10 @@ describe('Request.JSON', function(){ }}); this.requests[0].respond(200, {'Content-Type': 'text/json'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); // checks the first argument from the first call - expect(this.spy.args[0][0]).toEqual({ok: true}); + expect(this.spy.args[0][0]).to.deep.equal({ok: true}); }); @@ -54,10 +54,10 @@ describe('Request.JSON', function(){ }}); this.requests[0].respond(200, {'Content-Type': 'text/json'}, response); - expect(this.spy.called).toBe(true); + expect(this.spy.called).to.equal(true); // checks the first argument from the first call - expect(this.spy.args[0][0]).toEqual('{"ok":function(){invalid;}}'); + expect(this.spy.args[0][0]).to.equal('{"ok":function(){invalid;}}'); }); diff --git a/Specs/Request/Request.js b/Specs/Request/Request.js index 3c88d4de..6782797f 100644 --- a/Specs/Request/Request.js +++ b/Specs/Request/Request.js @@ -34,7 +34,7 @@ describe('Request', function(){ this.requests[0].respond(200, {'Content-Type': 'text/plain'}, 'res&ponsé'); // checks the first argument from the first call - expect(onComplete.args[0][0]).toEqual('res&ponsé'); + expect(onComplete.args[0][0]).to.equal('res&ponsé'); }); @@ -50,9 +50,9 @@ describe('Request', function(){ this.requests[0].respond(200, {'Content-Type': 'text/json'}, 'data'); - expect(onComplete.called).toBe(true); + expect(onComplete.called).to.equal(true); - expect(onComplete.args[0][0]).toEqual('data'); + expect(onComplete.args[0][0]).to.equal('data'); }); @@ -68,11 +68,11 @@ describe('Request', function(){ var requested = this.requests[0]; - expect(requested.method.toLowerCase()).toBe('post'); + expect(requested.method.toLowerCase()).to.equal('post'); requested.respond(200, {'Content-Type': 'text/plain'}, ''); - expect(onComplete.called).toBe(true); + expect(onComplete.called).to.equal(true); }); xdescribe('(async 1)', function(){ @@ -88,9 +88,9 @@ describe('Request', function(){ }); it('should create an ajax request and as it\'s an invalid XML, onComplete will receive null as the xml document', function(){ - expect(this.onComplete.called).toBe(true); - expect(this.onComplete.args[0][0]).toEqual('response'); - expect(this.request.response.text).toEqual('response'); + expect(this.onComplete.called).to.equal(true); + expect(this.onComplete.args[0][0]).to.equal('response'); + expect(this.request.response.text).to.equal('response'); }, 1500); }); @@ -114,10 +114,10 @@ describe('Request', function(){ }); it('should create an ajax request and as it\'s an invalid XML, onComplete will receive null as the xml document', function(){ - expect(this.chain.called).toBe(true); - expect(this.onComplete.called).toBe(true); - expect(this.onComplete.args[0][0]).toEqual('response'); - expect(this.request.response.text).toEqual('response'); + expect(this.chain.called).to.equal(true); + expect(this.onComplete.called).to.equal(true); + expect(this.onComplete.args[0][0]).to.equal('response'); + expect(this.request.response.text).to.equal('response'); }, 800); }); @@ -136,9 +136,9 @@ describe('Request', function(){ var requested = this.requests[0]; requested.respond(200, {'Content-Type': 'text/plain'}, requested.requestBody) - expect(onComplete.called).toBe(true); + expect(onComplete.called).to.equal(true); - expect(onComplete.args[0][0]).toEqual('__response=data'); + expect(onComplete.args[0][0]).to.equal('__response=data'); }); @@ -147,7 +147,7 @@ describe('Request', function(){ url: '/something/or/other' }).send(); - expect(request.xhr.withCredentials).toBeFalsy(); + expect(request.xhr.withCredentials).to.not.be.ok; }); /*<1.4compat>*/ @@ -158,7 +158,7 @@ describe('Request', function(){ user: 'someone' }).send(); - expect(request.xhr.withCredentials).toBe(true); + expect(request.xhr.withCredentials).to.equal(true); }); /**/ @@ -169,7 +169,7 @@ describe('Request', function(){ user: 'someone' }).send(); - expect(request.xhr.withCredentials).toBeFalsy(); + expect(request.xhr.withCredentials).to.not.be.ok; }); dit('should set xhr.withCredentials flag if options.withCredentials is set', function(){ @@ -178,6 +178,6 @@ describe('Request', function(){ withCredentials: true }).send(); - expect(request.xhr.withCredentials).toBe(true); + expect(request.xhr.withCredentials).to.equal(true); }); }); diff --git a/Specs/Types/Array.js b/Specs/Types/Array.js index f39c3539..a3d08483 100644 --- a/Specs/Types/Array.js +++ b/Specs/Types/Array.js @@ -22,16 +22,16 @@ describe("Array", function(){ it('should flatten a multidimensional array', function(){ var arr = [1,2,3,[4,5,[6,7,[8]]], [[[[[9]]]]]]; - expect(arr.flatten()).toEqual([1,2,3,4,5,6,7,8,9]); + expect(arr.flatten()).to.deep.equal([1,2,3,4,5,6,7,8,9]); }); it('should flatten arguments', function(){ var test = function(){ return Array.flatten(arguments); }; - expect(test(1,2,3)).toEqual([1,2,3]); - expect(test([1,2,3])).toEqual([1,2,3]); - expect(test(1,2,[3])).toEqual([1,2,3]); + expect(test(1,2,3)).to.deep.equal([1,2,3]); + expect(test([1,2,3])).to.deep.equal([1,2,3]); + expect(test(1,2,[3])).to.deep.equal([1,2,3]); }); // Array.filter @@ -39,7 +39,7 @@ describe("Array", function(){ it('should filter an array', function(){ var array = [1,2,3,0,0,0]; var arr = array.concat([false, null, 4]).filter(Type.isNumber); - expect(arr).toEqual(array.concat(4)); + expect(arr).to.deep.equal(array.concat(4)); }); it('filter should skip deleted elements', function(){ @@ -49,7 +49,7 @@ describe("Array", function(){ return true; }); - expect(i).toEqual(2); + expect(i).to.equal(2); }); // Array.clean @@ -57,7 +57,7 @@ describe("Array", function(){ it('should clean an array from undefined and null values', function(){ var array = [null, 1, 0, true, false, "foo", undefined]; var arr = array.clean(); - expect(arr).toEqual([1, 0, true, false, "foo"]); + expect(arr).to.deep.equal([1, 0, true, false, "foo"]); }); // Array.map @@ -67,7 +67,7 @@ describe("Array", function(){ return (item + 1); }); - expect(arr).toEqual([2,3,4,1,1,1]); + expect(arr).to.deep.equal([2,3,4,1,1,1]); }); it('map should skip deleted elements', function(){ @@ -76,15 +76,15 @@ describe("Array", function(){ return i++; }); - expect(i).toEqual(2); + expect(i).to.equal(2); }); // Array.every it('should return true if every item matches the comparator, otherwise false', function(){ - expect([1,2,3,0,0,0].every(Type.isNumber)).toBeTruthy(); + expect([1,2,3,0,0,0].every(Type.isNumber)).to.equal(true); - expect(['1',2,3,0].every(Type.isNumber)).toBeFalsy(); + expect(['1',2,3,0].every(Type.isNumber)).to.equal(false); }); it('every should skip deleted elements', function(){ @@ -94,15 +94,15 @@ describe("Array", function(){ return true; }); - expect(i).toEqual(2); + expect(i).to.equal(2); }); // Array.some it('should return true if some of the items in the array match the comparator, otherwise false', function(){ - expect(['1',2,3,0].some(Type.isNumber)).toBeTruthy(); + expect(['1',2,3,0].some(Type.isNumber)).to.equal(true); - expect([1,2,3,0,0,0].map(String).some(Type.isNumber)).toBeFalsy(); + expect([1,2,3,0,0,0].map(String).some(Type.isNumber)).to.equal(false); }); it('some should skip deleted elements', function(){ @@ -116,41 +116,41 @@ describe("Array", function(){ return true; }); - expect(i).toEqual(3); + expect(i).to.equal(3); }); // Array.indexOf it('should return the index of the item', function(){ - expect([1,2,3,0,0,0].indexOf(0)).toEqual(3); + expect([1,2,3,0,0,0].indexOf(0)).to.equal(3); }); it('should return -1 if the item is not found in the array', function(){ - expect([1,2,3,0,0,0].indexOf('not found')).toEqual(-1); + expect([1,2,3,0,0,0].indexOf('not found')).to.equal(-1); }); // Array.erase it('should remove all items in the array that match the specified item', function(){ var arr = [1,2,3,0,0,0].erase(0); - expect(arr).toEqual([1,2,3]); + expect(arr).to.deep.equal([1,2,3]); }); // Array.contains it('should return true if the array contains the specified item', function(){ - expect([1,2,3,0,0,0].contains(0)).toBeTruthy(); + expect([1,2,3,0,0,0].contains(0)).to.equal(true); }); it('should return false if the array does not contain the specified item', function(){ - expect([0,1,2].contains('not found')).toBeFalsy(); + expect([0,1,2].contains('not found')).to.equal(false); }); // Array.associate it('should associate an array with a specified array', function(){ var obj = [1,2,3,0,0,0].associate(['a', 'b', 'c', 'd']); - expect(obj).toEqual({a:1, b:2, c:3, d:0}); + expect(obj).to.deep.equal({a:1, b:2, c:3, d:0}); }); // Array.append @@ -159,8 +159,8 @@ describe("Array", function(){ var a = [1,2,4]; var b = [2,3,4,5]; a.append(b); - expect(a).toEqual([1,2,4,2,3,4,5]); - expect(b).toEqual([2,3,4,5]); + expect(a).to.deep.equal([1,2,4,2,3,4,5]); + expect(b).to.deep.equal([2,3,4,5]); }); var isType = function(type){ @@ -185,7 +185,7 @@ describe("Array", function(){ myBoolean: isType('boolean') }); - expect(assoc2).toEqual({ + expect(assoc2).to.deep.equal({ myNumber: 100, myElement: el, myObject: {foo: 'bar'}, @@ -200,8 +200,8 @@ describe("Array", function(){ var a = [1,2,4]; var b = [2,3,4,5]; a.extend(b); - expect(a).toEqual([1,2,4,2,3,4,5]); - expect(b).toEqual([2,3,4,5]); + expect(a).to.deep.equal([1,2,4,2,3,4,5]); + expect(b).to.deep.equal([2,3,4,5]); }); // @@ -209,40 +209,40 @@ describe("Array", function(){ var a = [1,2,4]; var b = [2,3,4,5]; a.append(b); - expect(a).toEqual([1,2,4,2,3,4,5]); - expect(b).toEqual([2,3,4,5]); + expect(a).to.deep.equal([1,2,4,2,3,4,5]); + expect(b).to.deep.equal([2,3,4,5]); }); // Array.combine it('should combine an array', function(){ var arr = [1,2,3,4].combine([3,1,4,5,6,7]); - expect(arr).toEqual([1,2,3,4,5,6,7]); + expect(arr).to.deep.equal([1,2,3,4,5,6,7]); }); // Array.include it('should include only new items', function(){ var arr = [1,2,3,4].include(1).include(5); - expect(arr).toEqual([1,2,3,4,5]); + expect(arr).to.deep.equal([1,2,3,4,5]); }); // Array.getLast it('should return the last item in the array', function(){ - expect([1,2,3,0,0,0].getLast()).toEqual(0); - expect([3].getLast()).toEqual(3); + expect([1,2,3,0,0,0].getLast()).to.equal(0); + expect([3].getLast()).to.equal(3); }); it('should return null if there are no items', function(){ - expect([].getLast()).toEqual(null); + expect([].getLast()).to.equal(null); }); // Array.empty it('should empty the array', function(){ var arr = [1,2,3,4].empty(); - expect(arr).toEqual([]); + expect(arr).to.deep.equal([]); }); }); @@ -252,38 +252,38 @@ describe("Array Color Methods", function(){ // Array.hexToRgb it('should return null if the length of the array is not 3', function(){ - expect([].hexToRgb()).toBeNull(); + expect([].hexToRgb()).to.equal(null); }); it('should return a CSS rgb string', function(){ - expect(['0','0','0'].hexToRgb()).toEqual('rgb(0,0,0)'); + expect(['0','0','0'].hexToRgb()).to.equal('rgb(0,0,0)'); }); it('should support shorthand hex', function(){ - expect(['c','c','c'].hexToRgb()).toEqual('rgb(204,204,204)'); + expect(['c','c','c'].hexToRgb()).to.equal('rgb(204,204,204)'); }); it('should return an array with 16-based numbers when passed true', function(){ - expect(['ff','ff','ff'].hexToRgb(true)).toEqual([255,255,255]); + expect(['ff','ff','ff'].hexToRgb(true)).to.deep.equal([255,255,255]); }); // Array.rgbToHex it('should return null if the array does not have at least 3 times', function(){ - expect([0,1].rgbToHex()).toBeNull(); + expect([0,1].rgbToHex()).to.equal(null); }); it('should return a css hexadecimal string', function(){ - expect(['255', '0', '0'].rgbToHex()).toEqual('#ff0000'); - expect([0,0,255].rgbToHex()).toEqual('#0000ff'); + expect(['255', '0', '0'].rgbToHex()).to.equal('#ff0000'); + expect([0,0,255].rgbToHex()).to.equal('#0000ff'); }); it('should return an array with hexadecimal string items', function(){ - expect([0,255,0].rgbToHex(true)).toEqual(['00', 'ff', '00']); + expect([0,255,0].rgbToHex(true)).to.deep.equal(['00', 'ff', '00']); }); it('should return `transparent` if the fourth item is 0 and first param is not true', function(){ - expect([0,0,0,0].rgbToHex()).toEqual('transparent'); + expect([0,0,0,0].rgbToHex()).to.equal('transparent'); }); }); @@ -293,15 +293,15 @@ describe('Array.getRandom', function(){ it('should get a random element from an array', function(){ var a = [1]; - expect(a.getRandom()).toEqual(1); + expect(a.getRandom()).to.equal(1); a.push(2); // Let's try a few times - expect(a).toContain(a.getRandom()); - expect(a).toContain(a.getRandom()); - expect(a).toContain(a.getRandom()); - expect(a).toContain(a.getRandom()); + expect(a).to.contain(a.getRandom()); + expect(a).to.contain(a.getRandom()); + expect(a).to.contain(a.getRandom()); + expect(a).to.contain(a.getRandom()); }); }); @@ -309,11 +309,11 @@ describe('Array.getRandom', function(){ describe('Array.pick', function(){ it('should pick a value that is not null from the array', function(){ - expect([null, undefined, true, 1].pick()).toEqual(true); + expect([null, undefined, true, 1].pick()).to.equal(true); }); it('should return null', function(){ - expect([].pick()).toBeNull(); + expect([].pick()).to.equal(null); }); }); @@ -325,24 +325,24 @@ describe('Array', function(){ it('should return an array with the same length', function(){ expect([1, 2, 3, undefined].map(function(v){ return v; - }).length).toEqual(4); + }).length).to.equal(4); }); it('shoud return an empty array when the thisArg does not has a length property', function(){ expect([].map.call({}, function(){ return 1; - })).toEqual([]); + })).to.deep.equal([]); }); }); it('should accept thisArgs without length property', function(){ var object = {}, fn = function(){}; - expect([].every.call(object, fn)).toBe(true); - expect([].filter.call(object, fn)).toEqual([]); - expect([].indexOf.call(object)).toEqual(-1); - expect([].map.call(object, fn)).toEqual([]); - expect([].some.call(object, fn)).toBe(false); + expect([].every.call(object, fn)).to.equal(true); + expect([].filter.call(object, fn)).to.deep.equal([]); + expect([].indexOf.call(object)).to.equal(-1); + expect([].map.call(object, fn)).to.deep.equal([]); + expect([].some.call(object, fn)).to.equal(false); }); describe('Array.filter', function(){ @@ -356,7 +356,7 @@ describe('Array', function(){ } }); - expect(result[0]).toEqual(1); + expect(result[0]).to.equal(1); }); }); diff --git a/Specs/Types/Function.js b/Specs/Types/Function.js index fdfe236c..4a863246 100644 --- a/Specs/Types/Function.js +++ b/Specs/Types/Function.js @@ -10,6 +10,8 @@ var dit = /*<1.2compat>*/xit || /**/it; // don't run unless no compa (function(){ +var MooTools = new String('MooTools'); + var fn = function(){ return Array.from(arguments).slice(); }; @@ -28,32 +30,27 @@ describe("Function Methods", function(){ // Function.create it('should return a new function', function(){ var fnc = $empty.create(); - expect($empty === fnc).toBeFalsy(); - }); - - it('should return a new function', function(){ - var fnc = $empty.create(); - expect($empty === fnc).toBeFalsy(); + expect($empty).to.not.equal(fnc); }); it('should return a new function with specified argument', function(){ var fnc = fn.create({'arguments': 'rocks'}); - expect(fnc()).toEqual(['rocks']); + expect(fnc()).to.deep.equal(['rocks']); }); it('should return a new function with multiple arguments', function(){ var fnc = fn.create({'arguments': ['MooTools', 'rocks']}); - expect(fnc()).toEqual(['MooTools', 'rocks']); + expect(fnc()).to.deep.equal(['MooTools', 'rocks']); }); it('should return a new function bound to an object', function(){ var fnc = Rules.create({'bind': 'MooTools'}); - expect(fnc()).toEqual('MooTools rules'); + expect(fnc()).to.equal('MooTools rules'); }); it('should return a new function as an event', function(){ var fnc = fn.create({'arguments': [0, 1], 'event': true}); - expect(fnc('an Event occurred')).toEqual(['an Event occurred', 0, 1]); + expect(fnc('an Event occurred')).to.deep.equal(['an Event occurred', 0, 1]); }); // @@ -61,40 +58,48 @@ describe("Function Methods", function(){ it('should return the function bound to an object', function(){ var fnc = Rules.bind('MooTools'); - expect(fnc()).toEqual('MooTools rules'); + expect(fnc()).to.equal('MooTools rules'); }); it('should return the function bound to an object with specified argument', function(){ - var results = Args.bind('MooTools', 'rocks')(); - expect(results[0] + '').toEqual(new String('MooTools') + ''); - expect(results[1]).toEqual('rocks'); + var results = Args.bind(MooTools, 'rocks')(); + expect(results[0]).to.equal(MooTools); + expect(results[1]).to.equal('rocks'); }); dit('should return the function bound to an object with multiple arguments', function(){ - var results = Args.bind('MooTools', ['rocks', 'da house'])(); - expect(results[0] + '').toEqual(new String('MooTools') + ''); - expect(results[1]).toEqual(['rocks', 'da house']); + var results = Args.bind(MooTools, ['rocks', 'da house'])(); + expect(results[0]).to.equal(MooTools); + expect(results[1]).to.deep.equal(['rocks', 'da house']); }); //<1.2compat> it('should return the function bound to an object with specified argument', function(){ - var fnc = Args.bind('MooTools', 'rocks'); - expect(fnc()).toEqual(['MooTools', 'rocks']); + var fnc = Args.bind(MooTools, 'rocks'); + var result = fnc(); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'rocks']); }); it('should return the function bound to an object with multiple arguments', function(){ - var fnc = Args.bind('MooTools', ['rocks', 'da house']); - expect(fnc()).toEqual(['MooTools', 'rocks', 'da house']); + var fnc = Args.bind(MooTools, ['rocks', 'da house']); + var result = fnc(); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'rocks', 'da house']); }); it('should return the function bound to an object and make the function an event listener', function(){ - var fnc = Args.bindWithEvent('MooTools'); - expect(fnc('an Event ocurred')).toEqual(['MooTools', 'an Event ocurred']); + var fnc = Args.bindWithEvent(MooTools); + var result = fnc('an Event occurred'); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'an Event occurred']); }); it('should return the function bound to an object and make the function event listener with multiple arguments', function(){ - var fnc = Args.bindWithEvent('MooTools', ['rocks', 'da house']); - expect(fnc('an Event ocurred')).toEqual(['MooTools', 'an Event ocurred', 'rocks', 'da house']); + var fnc = Args.bindWithEvent(MooTools, ['rocks', 'da house']); + var result = fnc('an Event occurred'); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'an Event occurred', 'rocks', 'da house']); }); // @@ -102,29 +107,32 @@ describe("Function Methods", function(){ it('should return a function that when called passes the specified arguments to the original function', function(){ var fnc = fn.pass('MooTools is beautiful and elegant'); - expect(fnc()).toEqual(['MooTools is beautiful and elegant']); + expect(fnc()).to.deep.equal(['MooTools is beautiful and elegant']); }); it('should pass multiple arguments and bind the function to a specific object when it is called', function(){ - var fnc = Args.pass(['rocks', 'da house'], 'MooTools'); - expect(fnc()).toEqual(['MooTools', 'rocks', 'da house']); + var fnc = Args.pass(['rocks', 'da house'], MooTools); + var result = fnc(); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'rocks', 'da house']); }); //<1.2compat> // Function.run it('should run the function', function(){ var result = fn.run(); - expect(result).toEqual([]); + expect(result).to.deep.equal([]); }); it('should run the function with multiple arguments', function(){ var result = fn.run(['MooTools', 'beautiful', 'elegant']); - expect(result).toEqual(['MooTools', 'beautiful', 'elegant']); + expect(result).to.deep.equal(['MooTools', 'beautiful', 'elegant']); }); it('should run the function with multiple arguments and bind the function to an object', function(){ - var result = Args.run(['beautiful', 'elegant'], 'MooTools'); - expect(result).toEqual(['MooTools', 'beautiful', 'elegant']); + var result = Args.run(['beautiful', 'elegant'], MooTools); + expect(result[0]).to.equal(MooTools); + expect(result).to.deep.equal([MooTools, 'beautiful', 'elegant']); }); // @@ -132,8 +140,8 @@ describe("Function Methods", function(){ it("should extend the function's properties", function(){ var fnc = (function(){}).extend({a: 1, b: 'c'}); - expect(fnc.a).toEqual(1); - expect(fnc.b).toEqual('c'); + expect(fnc.a).to.equal(1); + expect(fnc.b).to.equal('c'); }); @@ -148,14 +156,14 @@ describe("Function Methods", function(){ it("should return the function's return value", function(){ var fnc = Function.from('hello world!'); - expect(fnc.attempt()).toEqual('hello world!'); + expect(fnc.attempt()).to.equal('hello world!'); }); it('should return null if the function raises an exception', function(){ var fnc = function(){ this_should_not_work(); }; - expect(fnc.attempt()).toBeNull(); + expect(fnc.attempt()).to.equal(null); }); // Function.delay @@ -163,7 +171,7 @@ describe("Function Methods", function(){ it('delay should return a timer pointer', function(){ var referenceTimer = setTimeout(function(){}, 10000); var timer = (function(){}).delay(10000); - expect(typeOf(timer)).toEqual(typeOf(referenceTimer)); + expect(typeOf(timer)).to.equal(typeOf(referenceTimer)); clearTimeout(timer); clearTimeout(referenceTimer); }); @@ -173,7 +181,7 @@ describe("Function Methods", function(){ it('periodical should return a timer pointer', function(){ var referenceTimer = setInterval(function(){}, 10000); var timer = (function(){}).periodical(10000); - expect(typeOf(timer)).toEqual(typeOf(referenceTimer)); + expect(typeOf(timer)).to.equal(typeOf(referenceTimer)); clearInterval(timer); clearInterval(referenceTimer); }); @@ -194,8 +202,8 @@ describe('Function.attempt', function(){ calls++; return 'moo'; }); - expect(calls).toEqual(2); - expect(attempt).toEqual('success'); + expect(calls).to.equal(2); + expect(attempt).to.equal('success'); }); it('should return null when no function succeeded', function(){ @@ -207,8 +215,8 @@ describe('Function.attempt', function(){ calls++; return uninstall_ie(); }); - expect(calls).toEqual(2); - expect(attempt).toBeNull(); + expect(calls).to.equal(2); + expect(attempt).to.equal(null); }); }); @@ -220,11 +228,11 @@ describe('Function.bind', function(){ it('should return the function bound to an object', function(){ var spy = sinon.spy(); var f = spy.bind('MooTools'); - expect(spy.called).toBe(false); + expect(spy.called).to.equal(false); f(); - expect(spy.calledWith()).toBe(true); + expect(spy.calledWith()).to.equal(true); f('foo', 'bar'); - expect(spy.calledWith('foo', 'bar')).toBe(true); + expect(spy.calledWith('foo', 'bar')).to.equal(true); }); it('should return the function bound to an object with specified argument', function(){ @@ -232,9 +240,9 @@ describe('Function.bind', function(){ var spy = sinon.stub().returns('something'); var f = spy.bind(binding, 'arg'); - expect(spy.called).toBe(false); - expect(f('additional', 'arguments')).toEqual('something'); - expect(spy.lastCall.thisValue).toEqual(binding); + expect(spy.called).to.equal(false); + expect(f('additional', 'arguments')).to.equal('something'); + expect(spy.lastCall.thisValue).to.equal(binding); }); it('should return the function bound to an object with multiple arguments', function(){ @@ -242,9 +250,9 @@ describe('Function.bind', function(){ var spy = sinon.stub().returns('something'); var f = spy.bind(binding, ['foo', 'bar']); - expect(spy.called).toBe(false); - expect(f('additional', 'arguments')).toEqual('something'); - expect(spy.lastCall.thisValue).toEqual(binding); + expect(spy.called).to.equal(false); + expect(f('additional', 'arguments')).to.equal('something'); + expect(spy.lastCall.thisValue).to.equal(binding); }); dit('should still be possible to use it as constructor', function(){ @@ -257,7 +265,7 @@ describe('Function.bind', function(){ // `thisArg` should **not** be used for the `this` binding when called as a constructor var fuzzball = new Tribble('Klingon'); - expect(fuzzball.type).toEqual('Polygeminus grex'); + expect(fuzzball.type).to.equal('Polygeminus grex'); }); dit('when using .call(thisArg) on a bound function, it should ignore the thisArg of .call', function(){ @@ -265,14 +273,14 @@ describe('Function.bind', function(){ return [this.foo].concat(Array.slice(arguments)); }; - expect(fn.bind({foo: 'bar'})()).toEqual(['bar']); - expect(fn.bind({foo: 'bar'}, 'first').call({foo: 'yeah!'}, 'yooo')).toEqual(['bar', 'first', 'yooo']); + expect(fn.bind({foo: 'bar'})()).to.deep.equal(['bar']); + expect(fn.bind({foo: 'bar'}, 'first').call({foo: 'yeah!'}, 'yooo')).to.deep.equal(['bar', 'first', 'yooo']); var bound = fn.bind({foo: 'bar'}); var bound2 = fn.bind({foo: 'yep'}); var inst = new bound; inst.foo = 'noo!!'; - expect(bound2.call(inst, 'yoo', 'howdy')).toEqual(['yep', 'yoo', 'howdy']); + expect(bound2.call(inst, 'yoo', 'howdy')).to.deep.equal(['yep', 'yoo', 'howdy']); }); }); @@ -282,20 +290,20 @@ describe('Function.pass', function(){ it('should return a function that when called passes the specified arguments to the original function', function(){ var spy = sinon.stub().returns('the result'); var fnc = spy.pass('an argument'); - expect(spy.called).toBe(false); - expect(fnc('additional', 'arguments')).toBe('the result'); - expect(spy.calledWith('an argument')).toBe(true); - expect(spy.callCount).toBe(1); + expect(spy.called).to.equal(false); + expect(fnc('additional', 'arguments')).to.equal('the result'); + expect(spy.calledWith('an argument')).to.equal(true); + expect(spy.callCount).to.equal(1); }); it('should pass multiple arguments and bind the function to a specific object when it is called', function(){ var spy = sinon.stub().returns('the result'); var binding = {some: 'binding'}; var fnc = spy.pass(['multiple', 'arguments'], binding); - expect(spy.called).toBe(false); - expect(fnc('additional', 'arguments')).toBe('the result'); - expect(spy.lastCall.thisValue).toEqual(binding); - expect(spy.calledWith('multiple', 'arguments')).toBe(true); + expect(spy.called).to.equal(false); + expect(fnc('additional', 'arguments')).to.equal('the result'); + expect(spy.lastCall.thisValue).to.equal(binding); + expect(spy.calledWith('multiple', 'arguments')).to.equal(true); }); }); @@ -304,8 +312,8 @@ describe('Function.extend', function(){ it("should extend the function's properties", function(){ var fnc = (function(){}).extend({a: 1, b: 'c'}); - expect(fnc.a).toEqual(1); - expect(fnc.b).toEqual('c'); + expect(fnc.a).to.equal(1); + expect(fnc.b).to.equal('c'); }); }); @@ -321,14 +329,14 @@ describe('Function.attempt', function(){ it("should return the function's return value", function(){ var spy = sinon.stub().returns('hello world!'); - expect(spy.attempt()).toEqual('hello world!'); + expect(spy.attempt()).to.equal('hello world!'); }); it('should return null if the function raises an exception', function(){ var fnc = function(){ throw 'up'; }; - expect(fnc.attempt()).toBeNull(); + expect(fnc.attempt()).to.equal(null); }); }); @@ -353,13 +361,13 @@ describe('Function.delay', function(){ this.clock.tick(100); - expect(spyA.called).toBe(false); - expect(spyB.called).toBe(false); + expect(spyA.called).to.equal(false); + expect(spyB.called).to.equal(false); clearTimeout(timerB); this.clock.tick(250); - expect(spyA.callCount).toBe(1); - expect(spyB.callCount).toBe(0); + expect(spyA.callCount).to.equal(1); + expect(spyB.callCount).to.equal(0); }); it('should pass parameter 0', function(){ @@ -367,7 +375,7 @@ describe('Function.delay', function(){ spy.delay(50, null, 0); this.clock.tick(100); - expect(spy.calledWith(0)).toBe(true); + expect(spy.calledWith(0)).to.equal(true); }); it('should not pass any argument when no arguments passed', function(){ @@ -377,7 +385,7 @@ describe('Function.delay', function(){ }; spy.delay(50); this.clock.tick(100); - expect(argumentCount).toEqual(0); + expect(argumentCount).to.equal(0); }); }); @@ -397,19 +405,19 @@ describe('Function.periodical', function(){ var spy = sinon.spy(); var interval = spy.periodical(10); - expect(spy.called).toBe(false); + expect(spy.called).to.equal(false); this.clock.tick(100); - expect(spy.callCount).toBeGreaterThan(2); - expect(spy.callCount).toBeLessThan(15); + expect(spy.callCount).to.be.greaterThan(2); + expect(spy.callCount).to.be.lessThan(15); clearInterval(interval); spy.reset(); - expect(spy.called).toBe(false); + expect(spy.called).to.equal(false); this.clock.tick(100); - expect(spy.called).toBe(false); + expect(spy.called).to.equal(false); }); it('should pass parameter 0', function(){ @@ -418,7 +426,7 @@ describe('Function.periodical', function(){ this.clock.tick(100); - expect(spy.calledWith(0)).toBe(true); + expect(spy.calledWith(0)).to.equal(true); clearInterval(timer); }); @@ -430,7 +438,7 @@ describe('Function.periodical', function(){ var timer = spy.periodical(50); this.clock.tick(100); - expect(argumentCount).toEqual(0); + expect(argumentCount).to.equal(0); clearInterval(timer); }); diff --git a/Specs/Types/Hash.js b/Specs/Types/Hash.js index 0c968a61..6d851283 100644 --- a/Specs/Types/Hash.js +++ b/Specs/Types/Hash.js @@ -18,117 +18,117 @@ describe("Hash Methods", function(){ // Hash.constructor it('should return a new hash', function(){ - expect(Hash.type(new Hash())).toBeTruthy(); + expect(Hash.type(new Hash())).to.equal(true); }); it('should return a copy of a hash', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); var copy = new Hash(hash); - expect(copy !== hash).toBeTruthy(); - expect(copy).toEqual(hash); + expect(copy).to.not.equal(hash); + expect(copy).to.deep.equal(hash); }); // Hash.erase it('should remove a key and its value from the hash', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.erase('a')).toEqual(new Hash({b:2,c:3})); - expect(hash.erase('d')).toEqual(new Hash({b:2,c:3})); + expect(hash.erase('a')).to.deep.equal(new Hash({b:2,c:3})); + expect(hash.erase('d')).to.deep.equal(new Hash({b:2,c:3})); hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.erase('a')).toEqual(new Hash({b:2,c:3})); - expect(hash.erase('d')).toEqual(new Hash({b:2,c:3})); + expect(hash.erase('a')).to.deep.equal(new Hash({b:2,c:3})); + expect(hash.erase('d')).to.deep.equal(new Hash({b:2,c:3})); }); // Hash.get it('should return the value corresponding to the specified key otherwise null', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.get('c')).toEqual(3); - expect(hash.get('d')).toBeNull(); + expect(hash.get('c')).to.equal(3); + expect(hash.get('d')).to.equal(null); }); // Hash.set it('should set the key with the corresponding value', function(){ var myHash = new Hash({a: 1, b: 2, c: 3}).set('c', 7).set('d', 8); - expect(myHash).toEqual(new Hash({a:1,b:2,c:7,d:8})); + expect(myHash).to.deep.equal(new Hash({a:1,b:2,c:7,d:8})); }); // Hash.empty it('should empty the hash', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.empty()).toEqual(new Hash()); + expect(hash.empty()).to.deep.equal(new Hash()); }); // Hash.include it('should include a key value if the hash does not have the key otherwise ignore', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.include('e', 7)).toEqual(new Hash({a:1,b:2,c:3,e:7})); - expect(hash.include('a', 7)).toEqual(new Hash({a:1,b:2,c:3,e:7})); + expect(hash.include('e', 7)).to.deep.equal(new Hash({a:1,b:2,c:3,e:7})); + expect(hash.include('a', 7)).to.deep.equal(new Hash({a:1,b:2,c:3,e:7})); }); // Hash.keyOf | Hash.indexOf it('should return the key of the value or null if not found', function(){ var hash = new Hash({a: 1, b: 2, c: 3, d: 1}); - expect(hash.keyOf(1)).toEqual('a'); - expect(hash.keyOf('not found')).toBeNull(); + expect(hash.keyOf(1)).to.equal('a'); + expect(hash.keyOf('not found')).to.equal(null); - expect(hash.indexOf(1)).toEqual('a'); - expect(hash.indexOf('not found')).toBeNull(); + expect(hash.indexOf(1)).to.equal('a'); + expect(hash.indexOf('not found')).to.equal(null); }); // Hash.has it('should return true if the hash has the key otherwise false', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.has('a')).toBeTruthy(); - expect(hash.has('d')).toBeFalsy(); + expect(hash.has('a')).to.equal(true); + expect(hash.has('d')).to.equal(false); }); // Hash.hasValue | Hash.contains it('should return true if the hash hasValue otherwise false', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.hasValue(1)).toBeTruthy(); - expect(hash.hasValue('not found')).toBeFalsy(); + expect(hash.hasValue(1)).to.equal(true); + expect(hash.hasValue('not found')).to.equal(false); - expect(hash.contains(1)).toBeTruthy(); - expect(hash.contains('not found')).toBeFalsy(); + expect(hash.contains(1)).to.equal(true); + expect(hash.contains('not found')).to.equal(false); }); // Hash.getClean it('should getClean JavaScript object', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.getClean()).toEqual({a:1,b:2,c:3}); + expect(hash.getClean()).to.deep.equal({a:1,b:2,c:3}); }); // Hash.extend it('should extend a Hash with an object', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.extend({a:4,d:7,e:8})).toEqual(new Hash({a:4,b:2,c:3,d:7,e:8})); + expect(hash.extend({a:4,d:7,e:8})).to.deep.equal(new Hash({a:4,b:2,c:3,d:7,e:8})); }); it('should extend a Hash with another Hash', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.extend(new Hash({a:4,d:7,e:8}))).toEqual(new Hash({a:4,b:2,c:3,d:7,e:8})); + expect(hash.extend(new Hash({a:4,d:7,e:8}))).to.deep.equal(new Hash({a:4,b:2,c:3,d:7,e:8})); }); // Hash.combine it('should merge a Hash with an object', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.combine({a:4,d:7,e:8})).toEqual(new Hash({a:1,b:2,c:3,d:7,e:8})); + expect(hash.combine({a:4,d:7,e:8})).to.deep.equal(new Hash({a:1,b:2,c:3,d:7,e:8})); }); it('should merge a Hash with another Hash', function(){ var hash = new Hash({a: 1, b: 2, c: 3}); - expect(hash.combine(new Hash({a:4,d:7,e:8}))).toEqual(new Hash({a:1,b:2,c:3,d:7,e:8})); + expect(hash.combine(new Hash({a:4,d:7,e:8}))).to.deep.equal(new Hash({a:1,b:2,c:3,d:7,e:8})); }); // Hash.each @@ -139,66 +139,66 @@ describe("Hash Methods", function(){ hash.each(function(value, key){ newHash.set(key, value); }); - expect(newHash).toEqual(hash); + expect(newHash).to.deep.equal(hash); }); // Hash.map it('should map a new Hash according to the comparator', function(){ - expect(hash2.map(Number.type)).toEqual(new Hash({a:false,b:true,c:false})); + expect(hash2.map(Number.type)).to.deep.equal(new Hash({a:false,b:true,c:false})); }); // Hash.filter it('should filter the Hash according to the comparator', function(){ - expect(hash2.filter(Number.type)).toEqual(new Hash({b:233})); + expect(hash2.filter(Number.type)).to.deep.equal(new Hash({b:233})); }); // Hash.every it('should return true if every value matches the comparator, otherwise false', function(){ - expect(hash2.every($defined)).toBeTruthy(); - expect(hash2.every(Number.type)).toBeFalsy(); + expect(hash2.every($defined)).to.equal(true); + expect(hash2.every(Number.type)).to.equal(false); }); // Hash.some it('should return true if some of the values match the comparator, otherwise false', function(){ - expect(hash2.some(Number.type)).toBeTruthy(); - expect(hash2.some(Array.type)).toBeFalsy(); + expect(hash2.some(Number.type)).to.equal(true); + expect(hash2.some(Array.type)).to.equal(false); }); // Hash.getKeys it('getKeys should return an empty array', function(){ - expect(new Hash().getKeys()).toEqual([]); + expect(new Hash().getKeys()).to.deep.equal([]); }); it('should return an array containing the keys of the hash', function(){ - expect(hash2.getKeys()).toEqual(['a', 'b', 'c']); + expect(hash2.getKeys()).to.deep.equal(['a', 'b', 'c']); }); // Hash.getValues it('getValues should return an empty array', function(){ - expect(new Hash().getValues()).toEqual([]); + expect(new Hash().getValues()).to.deep.equal([]); }); it('should return an array with the values of the hash', function(){ - expect(hash2.getValues()).toEqual(['string', 233, {}]); + expect(hash2.getValues()).to.deep.equal(['string', 233, {}]); }); // Hash.toQueryString it('should return a query string', function(){ var myHash = new Hash({apple: "red", lemon: "yellow"}); - expect(myHash.toQueryString()).toEqual('apple=red&lemon=yellow'); + expect(myHash.toQueryString()).to.equal('apple=red&lemon=yellow'); var myHash2 = new Hash({apple: ['red', 'yellow'], lemon: ['green', 'yellow']}); - expect(myHash2.toQueryString()).toEqual('apple[0]=red&apple[1]=yellow&lemon[0]=green&lemon[1]=yellow'); + expect(myHash2.toQueryString()).to.equal('apple[0]=red&apple[1]=yellow&lemon[0]=green&lemon[1]=yellow'); var myHash3 = new Hash({fruits: {apple: ['red', 'yellow'], lemon: ['green', 'yellow']}}); - expect(myHash3.toQueryString()).toEqual('fruits[apple][0]=red&fruits[apple][1]=yellow&fruits[lemon][0]=green&fruits[lemon][1]=yellow'); + expect(myHash3.toQueryString()).to.equal('fruits[apple][0]=red&fruits[apple][1]=yellow&fruits[lemon][0]=green&fruits[lemon][1]=yellow'); }); }); diff --git a/Specs/Types/Number.js b/Specs/Types/Number.js index 7216b91d..da37bb48 100644 --- a/Specs/Types/Number.js +++ b/Specs/Types/Number.js @@ -11,49 +11,49 @@ describe("Number Methods", function(){ // Number.toInt it('should convert a number to an integer', function(){ - expect((111).toInt()).toEqual(111); + expect((111).toInt()).to.equal(111); }); it('should convert a number depending on the radix provided', function(){ - expect((111).toInt(2)).toEqual(7); - expect((0x16).toInt(10)).toEqual(22); //ECMA standard, radix is optional so if starts with 0x then parsed as hexadecimal - expect((016).toInt(10)).toEqual(14); //ECMA standard, radix is optional so if starts with 0 then parsed as octal + expect((111).toInt(2)).to.equal(7); + expect((0x16).toInt(10)).to.equal(22); //ECMA standard, radix is optional so if starts with 0x then parsed as hexadecimal + expect((016).toInt(10)).to.equal(14); //ECMA standard, radix is optional so if starts with 0 then parsed as octal }); // Number.toFloat it('should convert a number to a float', function(){ - expect((1.00).toFloat()).toEqual(1); - expect((1.12 - 0.12).toFloat()).toEqual(1); - expect((0.0010).toFloat()).toEqual(0.001); - expect((Number.MIN_VALUE).toFloat()).toEqual(Number.MIN_VALUE); + expect((1.00).toFloat()).to.equal(1); + expect((1.12 - 0.12).toFloat()).to.equal(1); + expect((0.0010).toFloat()).to.equal(0.001); + expect((Number.MIN_VALUE).toFloat()).to.equal(Number.MIN_VALUE); }); // Number.limit it('should limit a number within a range', function(){ - expect((-1).limit(0, 1)).toEqual(0); - expect((3).limit(1, 2)).toEqual(2); + expect((-1).limit(0, 1)).to.equal(0); + expect((3).limit(1, 2)).to.equal(2); }); it('should not limit a number if within the range', function(){ - expect((2).limit(0,4)).toEqual(2); + expect((2).limit(0,4)).to.equal(2); }); // Number.round it('should round a number to the nearest whole number if units place is not specified', function(){ - expect((0.01).round()).toEqual(0); + expect((0.01).round()).to.equal(0); }); it('should round a number according the units place specified', function(){ - expect((0.01).round(2)).toEqual(0.01); - expect((1).round(3)).toEqual(1); - expect((-1.01).round()).toEqual(-1); - expect((-1.01).round(2)).toEqual(-1.01); - expect((111).round(-1)).toEqual(110); - expect((-111).round(-2)).toEqual(-100); - expect((100).round(-5)).toEqual(0); + expect((0.01).round(2)).to.equal(0.01); + expect((1).round(3)).to.equal(1); + expect((-1.01).round()).to.equal(-1); + expect((-1.01).round(2)).to.equal(-1.01); + expect((111).round(-1)).to.equal(110); + expect((-111).round(-2)).to.equal(-100); + expect((100).round(-5)).to.equal(0); }); // Number.times @@ -69,8 +69,8 @@ describe("Number Methods", function(){ found2 = i; }); - expect(found).toEqual(2); - expect(found2).toEqual(-1); + expect(found).to.equal(2); + expect(found2).to.equal(-1); }); it('should bind and call the function for the specified number of times', function(){ @@ -79,7 +79,7 @@ describe("Number Methods", function(){ (1).times(function(i){ found3 = (this == aTest); }, aTest); - expect(found3).toBeTruthy(); + expect(found3).to.equal(true); }); }); @@ -92,7 +92,7 @@ describe("Number Methods", function(){ var example = {}; var b = value.test[1]; it('should return the ' + value.title + ' value of the number' + ((b) ? ' and the passed number' : ''), function(){ - expect(value.test[0][key](b)).toEqual(Math[key].apply(null, value.test)); + expect(value.test[0][key](b)).to.equal(Math[key].apply(null, value.test)); }); }); }); diff --git a/Specs/Types/Object.js b/Specs/Types/Object.js index 00ec7ca7..20acf021 100644 --- a/Specs/Types/Object.js +++ b/Specs/Types/Object.js @@ -15,7 +15,7 @@ describe("Object Methods", function(){ // Object subset it('should return an object with only the specified keys', function(){ - expect(Object.subset(object, ['a', 'b'])).toEqual({a:'string',b:233}); + expect(Object.subset(object, ['a', 'b'])).to.deep.equal({a:'string',b:233}); }); it('should ignore undefined keys', function(){ @@ -24,73 +24,73 @@ describe("Object Methods", function(){ d: null }; var subset = Object.subset(obj, ['a', 'b', 'c', 'd']); - expect(subset).toEqual({b: 'string', d: null}); + expect(subset).to.deep.equal({b: 'string', d: null}); // To equal doesn't check for undefined properties - expect('a' in subset).toBeFalsy(); - expect('c' in subset).toBeFalsy(); + expect('a' in subset).to.equal(false); + expect('c' in subset).to.equal(false); }); // Object keyOf it('should return the key of the value or null if not found', function(){ - expect(Object.keyOf(object, 'string')).toEqual('a'); - expect(Object.keyOf(object, 'not found')).toBeNull(); + expect(Object.keyOf(object, 'string')).to.equal('a'); + expect(Object.keyOf(object, 'not found')).to.equal(null); }); // Object.contains it('should return true if the object contains value otherwise false', function(){ - expect(Object.contains(object, 'string')).toBeTruthy(); - expect(Object.contains(object, 'not found')).toBeFalsy(); + expect(Object.contains(object, 'string')).to.equal(true); + expect(Object.contains(object, 'not found')).to.equal(false); }); // Object.map it('should map a new object according to the comparator', function(){ - expect(Object.map(object, Type.isNumber)).toEqual({a:false,b:true,c:false}); + expect(Object.map(object, Type.isNumber)).to.deep.equal({a:false,b:true,c:false}); }); // Object.filter it('should filter the object according to the comparator', function(){ - expect(Object.filter(object, Type.isNumber)).toEqual({b:233}); + expect(Object.filter(object, Type.isNumber)).to.deep.equal({b:233}); }); // Object.every it('should return true if every value matches the comparator, otherwise false', function(){ - expect(Object.every(object, typeOf)).toBeTruthy(); - expect(Object.every(object, Type.isNumber)).toBeFalsy(); + expect(Object.every(object, typeOf)).to.equal(true); + expect(Object.every(object, Type.isNumber)).to.equal(false); }); // Object.some it('should return true if some of the values match the comparator, otherwise false', function(){ - expect(Object.some(object, Type.isNumber)).toBeTruthy(); - expect(Object.some(object, Type.isArray)).toBeFalsy(); + expect(Object.some(object, Type.isNumber)).to.equal(true); + expect(Object.some(object, Type.isArray)).to.equal(false); }); // Object.values it('values should return an empty array', function(){ - expect(Object.values({})).toEqual([]); + expect(Object.values({})).to.deep.equal([]); }); it('should return an array with the values of the object', function(){ - expect(Object.values(object)).toEqual(['string', 233, {}]); + expect(Object.values(object)).to.deep.equal(['string', 233, {}]); }); // Object.toQueryString it('should return a query string', function(){ var myObject = {apple: "red", lemon: "yellow"}; - expect(Object.toQueryString(myObject)).toEqual('apple=red&lemon=yellow'); + expect(Object.toQueryString(myObject)).to.equal('apple=red&lemon=yellow'); var myObject2 = {apple: ['red', 'yellow'], lemon: ['green', 'yellow']}; - expect(Object.toQueryString(myObject2)).toEqual('apple[0]=red&apple[1]=yellow&lemon[0]=green&lemon[1]=yellow'); + expect(Object.toQueryString(myObject2)).to.equal('apple[0]=red&apple[1]=yellow&lemon[0]=green&lemon[1]=yellow'); var myObject3 = {fruits: {apple: ['red', 'yellow'], lemon: ['green', 'yellow']}}; - expect(Object.toQueryString(myObject3)).toEqual('fruits[apple][0]=red&fruits[apple][1]=yellow&fruits[lemon][0]=green&fruits[lemon][1]=yellow'); + expect(Object.toQueryString(myObject3)).to.equal('fruits[apple][0]=red&fruits[apple][1]=yellow&fruits[lemon][0]=green&fruits[lemon][1]=yellow'); }); }); @@ -106,11 +106,11 @@ describe('Object.getLength', function(){ b: false }; - expect(Object.getLength(object)).toEqual(5); + expect(Object.getLength(object)).to.equal(5); object.n = null; - expect(Object.getLength(object)).toEqual(5); + expect(Object.getLength(object)).to.equal(5); }); }); @@ -129,7 +129,7 @@ describe('Object hasOwnProperty', function(){ Object.every(window, fn); Object.some(window, fn); Object.keyOf(window, document); - }).not.toThrow(); + }).to.not.throw(Error); }); }); diff --git a/Specs/Types/String.js b/Specs/Types/String.js index a2c3096e..e9af28ca 100644 --- a/Specs/Types/String.js +++ b/Specs/Types/String.js @@ -11,134 +11,134 @@ describe("String Methods", function(){ // String.capitalize it('should capitalize each word', function(){ - expect('i like cookies'.capitalize()).toEqual('I Like Cookies'); - expect('I Like cOOKIES'.capitalize()).toEqual('I Like COOKIES'); + expect('i like cookies'.capitalize()).to.equal('I Like Cookies'); + expect('I Like cOOKIES'.capitalize()).to.equal('I Like COOKIES'); }); // String.camelCase it('should convert a hyphenated string into a camel cased string', function(){ - expect('i-like-cookies'.camelCase()).toEqual('iLikeCookies'); - expect('I-Like-Cookies'.camelCase()).toEqual('ILikeCookies'); + expect('i-like-cookies'.camelCase()).to.equal('iLikeCookies'); + expect('I-Like-Cookies'.camelCase()).to.equal('ILikeCookies'); }); // String.hyphenate it('should convert a camel cased string into a hyphenated string', function(){ - expect('iLikeCookies'.hyphenate()).toEqual('i-like-cookies'); - expect('ILikeCookies'.hyphenate()).toEqual('-i-like-cookies'); + expect('iLikeCookies'.hyphenate()).to.equal('i-like-cookies'); + expect('ILikeCookies'.hyphenate()).to.equal('-i-like-cookies'); }); // String.clean it('should clean all extraneous whitespace from the string', function(){ - expect(' i like cookies '.clean()).toEqual("i like cookies"); - expect(' i\nlike \n cookies \n\t '.clean()).toEqual("i like cookies"); + expect(' i like cookies '.clean()).to.equal("i like cookies"); + expect(' i\nlike \n cookies \n\t '.clean()).to.equal("i like cookies"); }); // String.trim it('should trim left and right whitespace from the string', function(){ - expect(' i like cookies '.trim()).toEqual('i like cookies'); - expect(' i \tlike cookies '.trim()).toEqual('i \tlike cookies'); + expect(' i like cookies '.trim()).to.equal('i like cookies'); + expect(' i \tlike cookies '.trim()).to.equal('i \tlike cookies'); }); //<1.4compat> // String.contains it('should return true if the string contains a string otherwise false', function(){ - expect('i like cookies'.contains('cookies')).toBeTruthy(); - expect('i,like,cookies'.contains('cookies')).toBeTruthy(); - expect('mootools'.contains('inefficient javascript')).toBeFalsy(); + expect('i like cookies'.contains('cookies')).to.equal(true); + expect('i,like,cookies'.contains('cookies')).to.equal(true); + expect('mootools'.contains('inefficient javascript')).to.equal(false); }); it('should return true if the string constains the string and separator otherwise false', function(){ - expect('i like cookies'.contains('cookies', ' ')).toBeTruthy(); - expect('i like cookies'.contains('cookies', ',')).toBeFalsy(); + expect('i like cookies'.contains('cookies', ' ')).to.equal(true); + expect('i like cookies'.contains('cookies', ',')).to.equal(false); - expect('i,like,cookies'.contains('cookies', ' ')).toBeFalsy(); - expect('i,like,cookies'.contains('cookies', ',')).toBeTruthy(); + expect('i,like,cookies'.contains('cookies', ' ')).to.equal(false); + expect('i,like,cookies'.contains('cookies', ',')).to.equal(true); }); // // String.test it('should return true if the test matches the string otherwise false', function(){ - expect('i like teh cookies'.test('cookies')).toBeTruthy(); - expect('i like cookies'.test('ke coo')).toBeTruthy(); - expect('I LIKE COOKIES'.test('cookie', 'i')).toBeTruthy(); - expect('i like cookies'.test('cookiez')).toBeFalsy(); + expect('i like teh cookies'.test('cookies')).to.equal(true); + expect('i like cookies'.test('ke coo')).to.equal(true); + expect('I LIKE COOKIES'.test('cookie', 'i')).to.equal(true); + expect('i like cookies'.test('cookiez')).to.equal(false); }); it('should return true if the regular expression test matches the string otherwise false', function(){ - expect('i like cookies'.test(/like/)).toBeTruthy(); - expect('i like cookies'.test(/^l/)).toBeFalsy(); + expect('i like cookies'.test(/like/)).to.equal(true); + expect('i like cookies'.test(/^l/)).to.equal(false); }); // String.toInt it('should convert the string into an integer', function(){ - expect('10'.toInt()).toEqual(10); - expect('10px'.toInt()).toEqual(10); - expect('10.10em'.toInt()).toEqual(10); + expect('10'.toInt()).to.equal(10); + expect('10px'.toInt()).to.equal(10); + expect('10.10em'.toInt()).to.equal(10); }); it('should convert the string into an integer with a specific base', function(){ - expect('10'.toInt(5)).toEqual(5); + expect('10'.toInt(5)).to.equal(5); }); // String.toFloat it('should convert the string into a float', function(){ - expect('10.11'.toFloat()).toEqual(10.11); - expect('10.55px'.toFloat()).toEqual(10.55); + expect('10.11'.toFloat()).to.equal(10.11); + expect('10.55px'.toFloat()).to.equal(10.55); }); // String.rgbToHex it('should convert the string into a CSS hex string', function(){ - expect('rgb(255,255,255)'.rgbToHex()).toEqual('#ffffff'); - expect('rgb(255,255,255,0)'.rgbToHex()).toEqual('transparent'); + expect('rgb(255,255,255)'.rgbToHex()).to.equal('#ffffff'); + expect('rgb(255,255,255,0)'.rgbToHex()).to.equal('transparent'); }); // String.hexToRgb it('should convert the CSS hex string into a CSS rgb string', function(){ - expect('#fff'.hexToRgb()).toEqual('rgb(255,255,255)'); - expect('ff00'.hexToRgb()).toEqual('rgb(255,0,0)'); - expect('#000000'.hexToRgb()).toEqual('rgb(0,0,0)'); + expect('#fff'.hexToRgb()).to.equal('rgb(255,255,255)'); + expect('ff00'.hexToRgb()).to.equal('rgb(255,0,0)'); + expect('#000000'.hexToRgb()).to.equal('rgb(0,0,0)'); }); // String.substitute it('should substitute values from objects', function(){ - expect('This is {color}.'.substitute({'color': 'blue'})).toEqual('This is blue.'); - expect('This is {color} and {size}.'.substitute({'color': 'blue', 'size': 'small'})).toEqual('This is blue and small.'); + expect('This is {color}.'.substitute({'color': 'blue'})).to.equal('This is blue.'); + expect('This is {color} and {size}.'.substitute({'color': 'blue', 'size': 'small'})).to.equal('This is blue and small.'); }); it('should substitute values from arrays', function(){ - expect('This is {0}.'.substitute(['blue'])).toEqual('This is blue.'); - expect('This is {0} and {1}.'.substitute(['blue', 'small'])).toEqual('This is blue and small.'); + expect('This is {0}.'.substitute(['blue'])).to.equal('This is blue.'); + expect('This is {0} and {1}.'.substitute(['blue', 'small'])).to.equal('This is blue and small.'); }); it('should remove undefined values', function(){ - expect('Checking {0}, {1}, {2}, {3} and {4}.'.substitute([1, 0, undefined, null])).toEqual('Checking 1, 0, , and .'); - expect('This is {not-set}.'.substitute({})).toEqual('This is .'); + expect('Checking {0}, {1}, {2}, {3} and {4}.'.substitute([1, 0, undefined, null])).to.equal('Checking 1, 0, , and .'); + expect('This is {not-set}.'.substitute({})).to.equal('This is .'); }); it('should ignore escaped placeholders', function(){ - expect('Ignore \\{this} but not {that}.'.substitute({'that': 'the others'})).toEqual('Ignore {this} but not the others.'); + expect('Ignore \\{this} but not {that}.'.substitute({'that': 'the others'})).to.equal('Ignore {this} but not the others.'); }); it('should substitute with a custom regex', function(){ var php = (/\$([\w-]+)/g); - expect('I feel so $language.'.substitute({'language': 'PHP'}, php)).toEqual('I feel so PHP.'); + expect('I feel so $language.'.substitute({'language': 'PHP'}, php)).to.equal('I feel so PHP.'); var ror = (/#\{([^}]+)\}/g); - expect('I feel so #{language}.'.substitute({'language': 'RoR'}, ror)).toEqual('I feel so RoR.'); + expect('I feel so #{language}.'.substitute({'language': 'RoR'}, ror)).to.equal('I feel so RoR.'); }); it('should substitute without goofing up nested curly braces', function(){ - expect("fred {is {not} very} cool".substitute({ 'is {not':'BROKEN' })).not.toEqual("fred BROKEN very} cool"); - expect('this {should {break} mo} betta'.substitute({ 'break':'work' })).toEqual('this {should work mo} betta'); + expect("fred {is {not} very} cool".substitute({ 'is {not':'BROKEN' })).to.not.equal("fred BROKEN very} cool"); + expect('this {should {break} mo} betta'.substitute({ 'break':'work' })).to.equal('this {should work mo} betta'); }); }); diff --git a/Specs/Utilities/Cookie.js b/Specs/Utilities/Cookie.js index b3531315..a7ed94ec 100644 --- a/Specs/Utilities/Cookie.js +++ b/Specs/Utilities/Cookie.js @@ -21,11 +21,11 @@ describe('Cookie', function(){ Cookie.write('key', 'value', options); - expect(Cookie.read('key', options)).toBe('value'); + expect(Cookie.read('key', options)).to.equal('value'); Cookie.dispose('key', options); - expect(Cookie.read('key', options)).toBeNull(); + expect(Cookie.read('key', options)).to.equal(null); }); it('should set HttpCookie flag correctly', function(){ @@ -36,7 +36,7 @@ describe('Cookie', function(){ } }).write('value'); - expect(instance.options.document.cookie.indexOf('HttpOnly')).not.toBe(-1); + expect(instance.options.document.cookie.indexOf('HttpOnly')).to.not.equal(-1); }); }); diff --git a/Specs/Utilities/JSON.js b/Specs/Utilities/JSON.js index 9e0112ff..5a175d51 100644 --- a/Specs/Utilities/JSON.js +++ b/Specs/Utilities/JSON.js @@ -27,7 +27,7 @@ describe('JSON', function(){ } }; - expect(JSON.decode(JSON.encode(object))).toEqual(object); + expect(JSON.decode(JSON.encode(object))).to.deep.equal(object); }); }); @@ -38,11 +38,11 @@ describe('JSON', function(){ var badString = 'alert("I\'m a bad string!")'; it('should parse a valid JSON string by default', function(){ - expect(typeOf(JSON.decode(goodString))).toEqual("object"); + expect(typeOf(JSON.decode(goodString))).to.equal("object"); }); it('should parse a valid JSON string when secure is set to false', function(){ - expect(typeOf(JSON.decode(goodString, false))).toEqual("object"); + expect(typeOf(JSON.decode(goodString, false))).to.equal("object"); }); it('should parse a hazarous string when secure is set to false', function(){ @@ -51,7 +51,7 @@ describe('JSON', function(){ if (string == "I'm a bad string!") return true; return false; }; - expect(JSON.decode(badString, false)).toEqual(true); + expect(JSON.decode(badString, false)).to.equal(true); win.alert = _old_alert; }); it('should parse a hazarous string when JSON.secure is set to false and secure is not defined', function(){ @@ -61,7 +61,7 @@ describe('JSON', function(){ return false; }; JSON.secure = false; - expect(JSON.decode(badString)).toEqual(true); + expect(JSON.decode(badString)).to.equal(true); win.alert = _old_alert; JSON.secure = true; }); @@ -72,7 +72,7 @@ describe('JSON', function(){ } catch (e){ err = !!e; }; - expect(err).toEqual(true); + expect(err).to.equal(true); }); }); diff --git a/Tests/gruntfile-options.js b/Tests/gruntfile-options.js index 6a2a9162..ba2e5103 100644 --- a/Tests/gruntfile-options.js +++ b/Tests/gruntfile-options.js @@ -88,7 +88,7 @@ var gruntOptions = { var karmaOptions = { captureTimeout: 60000 * 2, singleRun: true, - frameworks: ['jasmine', 'sinon', 'syn'], + frameworks: ['chai', 'jasmine', 'sinon', 'syn'], plugins: ['karma-*', path.resolve('Tests/Plugins/syn')], files: ['mootools-*.js'], sauceLabs: { diff --git a/Tests/server-tests.js b/Tests/server-tests.js index 971ea0ce..f6e2078e 100644 --- a/Tests/server-tests.js +++ b/Tests/server-tests.js @@ -1,9 +1,13 @@ "use strict"; var Jasmine = require('jasmine'), + chai = require('chai'), sinon = require('sinon'); function injectLibraries(object){ + object.should = chai.should(); + object.expect = chai.expect; + object.assert = chai.assert; object.sinon = sinon; } diff --git a/package.json b/package.json index 4873028e..d170c7ba 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "homepage": "http://mootools.net", "devDependencies": { + "chai": "^3.3", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "grunt-contrib-clean": "^0.6.0", @@ -39,6 +40,7 @@ "jasmine-core": "^2.3", "js-yaml": "^3.4", "karma": "^0.12.37", + "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.2.0", "karma-firefox-launcher": "^0.1.6", "karma-ie-launcher": "^0.2.0", -- 2.11.4.GIT