Skip to content

Commit

Permalink
Merge pull request #2737 from timwienk/spec-update-part-6
Browse files Browse the repository at this point in the history
Spec update part 6
  • Loading branch information
Arian Stolwijk committed Oct 1, 2015
2 parents 1d6c908 + 15e20d9 commit d7a0775
Show file tree
Hide file tree
Showing 29 changed files with 1,335 additions and 1,314 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](https://github.com/Automattic/expect.js#api).
3. Fix the bug.
4. Build and run the specs.
5. Push to your GitHub fork.
Expand Down
42 changes: 21 additions & 21 deletions Specs/Browser/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();');
});

});
Expand All @@ -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(){}');
});

});
Expand All @@ -39,16 +39,16 @@ describe('Browser.exec', function(){
describe('String.stripScripts', function(){

it('should strip all script tags from a string', function(){
expect('<div><script type="text/javascript" src="file.js"></script></div>'.stripScripts()).toEqual('<div></div>');
expect('<div><script type="text/javascript" src="file.js"></script></div>'.stripScripts()).to.equal('<div></div>');
});

it('should execute the stripped tags from the string', function(){
expect('<div><script type="text/javascript"> var stripScriptsSpec = 42; </script></div>'.stripScripts(true)).toEqual('<div></div>');
expect(window.stripScriptsSpec).toEqual(42);
expect('<div><script>\n// <!--\nvar stripScriptsSpec = 24;\n//-->\n</script></div>'.stripScripts(true)).toEqual('<div></div>');
expect(window.stripScriptsSpec).toEqual(24);
expect('<div><script>\n/*<![CDATA[*/\nvar stripScriptsSpec = 4242;\n/*]]>*/</script></div>'.stripScripts(true)).toEqual('<div></div>');
expect(window.stripScriptsSpec).toEqual(4242);
expect('<div><script type="text/javascript"> var stripScriptsSpec = 42; </script></div>'.stripScripts(true)).to.equal('<div></div>');
expect(window.stripScriptsSpec).to.equal(42);
expect('<div><script>\n// <!--\nvar stripScriptsSpec = 24;\n//-->\n</script></div>'.stripScripts(true)).to.equal('<div></div>');
expect(window.stripScriptsSpec).to.equal(24);
expect('<div><script>\n/*<![CDATA[*/\nvar stripScriptsSpec = 4242;\n/*]]>*/</script></div>'.stripScripts(true)).to.equal('<div></div>');
expect(window.stripScriptsSpec).to.equal(4242);
});

});
Expand All @@ -57,19 +57,19 @@ 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');
});

});

describe('Window', function(){

it('should set the Element prototype', function(){
expect(window.Element.prototype).toBeDefined();
expect(window.Element.prototype).to.not.equal(undefined);
});

});
Expand All @@ -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);
}
});
//</1.4compat>

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');
});

});
Expand Down Expand Up @@ -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){
Expand Down
92 changes: 46 additions & 46 deletions Specs/Class/Class.Extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ describe('Chain', function(){
return str;
});
var ret;
expect(arr).toEqual([]);
expect(arr).to.eql([]);
ret = chain.callChain("a", "A");
expect(ret).toEqual("0Aa");
expect(arr).toEqual(["0Aa"]);
expect(ret).to.equal("0Aa");
expect(arr).to.eql(["0Aa"]);

ret = chain.callChain("b", "B");
expect(ret).toEqual("1Bb");
expect(arr).toEqual(["0Aa", "1Bb"]);
expect(ret).to.equal("1Bb");
expect(arr).to.eql(["0Aa", "1Bb"]);

ret = chain.callChain();
expect(ret).toEqual(false);
expect(arr).toEqual(["0Aa", "1Bb"]);
expect(ret).to.equal(false);
expect(arr).to.eql(["0Aa", "1Bb"]);
});

it('should chain any number of functions', function(){
Expand All @@ -59,18 +59,18 @@ describe('Chain', function(){
arr.push(1);
});

expect(arr).toEqual([]);
expect(arr).to.eql([]);
chain.callChain();
expect(arr).toEqual([0]);
expect(arr).to.eql([0]);
chain.chain(function(){
arr.push(2);
});
chain.callChain();
expect(arr).toEqual([0, 1]);
expect(arr).to.eql([0, 1]);
chain.callChain();
expect(arr).toEqual([0, 1, 2]);
expect(arr).to.eql([0, 1, 2]);
chain.callChain();
expect(arr).toEqual([0, 1, 2]);
expect(arr).to.eql([0, 1, 2]);
});

it('should allow an array of functions', function(){
Expand All @@ -85,15 +85,15 @@ describe('Chain', function(){
arr.push(2);
}]);

expect(arr).toEqual([]);
expect(arr).to.eql([]);
chain.callChain();
expect(arr).toEqual([0]);
expect(arr).to.eql([0]);
chain.callChain();
expect(arr).toEqual([0, 1]);
expect(arr).to.eql([0, 1]);
chain.callChain();
expect(arr).toEqual([0, 1, 2]);
expect(arr).to.eql([0, 1, 2]);
chain.callChain();
expect(arr).toEqual([0, 1, 2]);
expect(arr).to.eql([0, 1, 2]);
});

it('each instance should have its own chain', function(){
Expand All @@ -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(){
Expand All @@ -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;
});

Expand All @@ -146,7 +146,7 @@ describe('Chain', function(){
test++;
}).callChain();

expect(test).toEqual(1);
expect(test).to.equal(1);
});

});
Expand All @@ -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(){
Expand All @@ -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(){
Expand All @@ -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(){
Expand All @@ -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(){
Expand All @@ -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(){
Expand All @@ -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(){
Expand All @@ -250,10 +250,10 @@ describe('Events API: Mixin', function(){
}).addEvent('event', three);

object[fire]('event');
expect(methods).toEqual([1, 2]);
expect(methods).to.eql([1, 2]);

object[fire]('event');
expect(methods).toEqual([1, 2, 1, 2]);
expect(methods).to.eql([1, 2, 1, 2]);
});

it('should be able to remove itself', function(){
Expand All @@ -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.eql([1, 2, 3]);

object[fire]('event');
expect(methods).toEqual([1, 2, 3, 3]);
expect(methods).to.eql([1, 2, 3, 3]);
});

});
Expand All @@ -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);
});

});
Expand Down Expand Up @@ -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);
});

});
Expand All @@ -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);
});

});
Loading

0 comments on commit d7a0775

Please sign in to comment.