diff --git a/test/expect-0.2.0-ol3/expect.js b/test/expect-0.2.0-ol3/expect.js index 6c2ec48248..562b781aee 100644 --- a/test/expect-0.2.0-ol3/expect.js +++ b/test/expect-0.2.0-ol3/expect.js @@ -492,50 +492,6 @@ return this; }; - /** - * Assert that that objects intersect. - * FIXME this is ol3 specific - * - * @param {Object} other - * - * @api public - */ - Assertion.prototype.intersect = - Assertion.prototype.wentToSchoolWith = function(other) { - this.assert( - this.obj.intersects(other) - , function(){ return 'expected ' + i(this.obj) + ' to intersect ' + i(other) } - , function(){ return 'expected ' + i(this.obj) + ' not to intersect ' + i(other) }); - return this; - }; - - /** - * Assert that arrays have the same value. - * - * @param {Array} other - * - * @api public - */ - Assertion.prototype.equalArray = - Assertion.prototype.preferItBeforeItWasFamous = function(other) { - var equal = this.obj.length == other.length; - if (equal) { - var j = 0; - for (j = 0; j < other.length; ++j) { - if (this.obj[j] !== other[j] && - !(isNaN(this.obj[j]) && isNaN(other[j]))) { - equal = false; - break; - } - } - } - this.assert( - equal - , function(){ return 'expected ' + i(this.obj) + ' to have the same array value as ' + i(other) } - , function(){ return 'expected ' + i(this.obj) + ' not to have the same array value as ' + i(other) }); - return this; - }; - /** * Assert a failure. * @@ -946,7 +902,11 @@ // 7.3. Other pairs that do not both pass typeof value == "object", // equivalence is determined by ==. } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; + if (isNaN(actual) && isNaN(expected)) { + return true; + } else { + return actual == expected; + } // 7.4. For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified diff --git a/test/mocha-1.8.1/mocha.js b/test/mocha-1.8.1/mocha.js index f01d356ac5..48989958a9 100644 --- a/test/mocha-1.8.1/mocha.js +++ b/test/mocha-1.8.1/mocha.js @@ -2370,6 +2370,12 @@ function HTML(runner, root) { } el.appendChild(fragment('
%e', str)); + + // Display errors in Chrome's console + if (window.chrome) { + window.console.error(str); + } + } // toggle code diff --git a/test/spec/ol/collection.test.js b/test/spec/ol/collection.test.js index d75f61457f..30e646d83f 100644 --- a/test/spec/ol/collection.test.js +++ b/test/spec/ol/collection.test.js @@ -29,7 +29,7 @@ describe('ol.collection', function() { it('adds elements to the collection', function() { collection.push(1); expect(collection.getLength()).to.eql(1); - expect(collection.getArray()).to.equalArray([1]); + expect(collection.getArray()).to.eql([1]); expect(collection.getAt(0)).to.eql(1); }); }); @@ -267,7 +267,7 @@ describe('ol.collection', function() { it('adds elements to end of the collection', function() { collection.extend([1, 2]); expect(collection.getLength()).to.eql(2); - expect(collection.getArray()).to.equalArray([1, 2]); + expect(collection.getArray()).to.eql([1, 2]); expect(collection.getAt(0)).to.eql(1); expect(collection.getAt(1)).to.eql(2); }); diff --git a/test/spec/ol/expect.test.js b/test/spec/ol/expect.test.js index 427c861da7..e3f1cab072 100644 --- a/test/spec/ol/expect.test.js +++ b/test/spec/ol/expect.test.js @@ -89,43 +89,4 @@ describe('expect.js', function() { }); - describe('equalArray', function() { - - it('knows who\'s cool', function() { - expect(['me']).to.equalArray(['me']); - }); - - it('knows who isn\'t', function() { - expect(['you']).not.to.equalArray([]); - }); - - }); - - describe('preferItBeforeItWasFamous', function() { - - it('respects the artist\'s privacy', function() { - expect(function() { - expect(['David', 'Bowie']).to.preferItBeforeItWasFamous( - ['David', 'Robert', 'Jones']); - }).to.throwException(); - }); - - it('prefers to keep some things quiet', function() { - expect(function() { - expect(['Cyrus']).to.preferItBeforeItWasFamous(['Cyrus']); - }).not.to.throwException(); - - }); - - }); - - describe('equalArray and preferItBeforeItWasFamous', function() { - - it('should record a duet together \u266c', function() { - expect(expect(['David Bowie']).to.equalArray).to.be( - expect(['Miley Cyrus']).to.preferItBeforeItWasFamous); - }); - - }); - }); diff --git a/test/spec/ol/structs/buffer.test.js b/test/spec/ol/structs/buffer.test.js index 1b6b019038..2e3710cfa3 100644 --- a/test/spec/ol/structs/buffer.test.js +++ b/test/spec/ol/structs/buffer.test.js @@ -27,7 +27,7 @@ describe('ol.structs.Buffer', function() { }); it('constructs a populated instance', function() { - expect(b.getArray()).to.equalArray([0, 1, 2, 3]); + expect(b.getArray()).to.eql([0, 1, 2, 3]); }); }); @@ -80,7 +80,7 @@ describe('ol.structs.Buffer', function() { it('allows elements to be added', function() { expect(b.add([0, 1, 2, 3])).to.be(0); - expect(b.getArray()).to.equalArray([0, 1, 2, 3]); + expect(b.getArray()).to.eql([0, 1, 2, 3]); }); }); @@ -128,7 +128,7 @@ describe('ol.structs.Buffer', function() { var callback = sinon.spy(); b.forEachRange(callback); expect(callback.calledOnce).to.be(true); - expect(callback.args[0]).to.equalArray([0, 4]); + expect(callback.args[0]).to.eql([0, 4]); }); }); @@ -155,7 +155,7 @@ describe('ol.structs.Buffer', function() { it('updates the items', function() { b.set([5, 6], 2); - expect(b.getArray()).to.equalArray([0, 1, 5, 6]); + expect(b.getArray()).to.eql([0, 1, 5, 6]); }); it('marks the set items as dirty', function() { @@ -164,7 +164,7 @@ describe('ol.structs.Buffer', function() { expect(dirtySet.isEmpty()).to.be(true); b.set([5, 6], 2); expect(dirtySet.isEmpty()).to.be(false); - expect(dirtySet.getArray()).to.equalArray([2, 4]); + expect(dirtySet.getArray()).to.eql([2, 4]); }); }); @@ -184,7 +184,7 @@ describe('ol.structs.Buffer', function() { it('allows more items to be added', function() { expect(b.add([4, 5, 6, 7])).to.be(4); - expect(b.getArray()).to.equalArray([0, 1, 2, 3, 4, 5, 6, 7]); + expect(b.getArray()).to.eql([0, 1, 2, 3, 4, 5, 6, 7]); }); }); @@ -195,7 +195,7 @@ describe('ol.structs.Buffer', function() { var callback = sinon.spy(); b.forEachRange(callback); expect(callback.calledOnce).to.be(true); - expect(callback.args[0]).to.equalArray([0, 4]); + expect(callback.args[0]).to.eql([0, 4]); }); }); @@ -213,7 +213,7 @@ describe('ol.structs.Buffer', function() { it('returns the expected set', function() { var freeSet = b.getFreeSet(); expect(freeSet.isEmpty()).to.be(false); - expect(freeSet.getArray()).to.equalArray([4, 8]); + expect(freeSet.getArray()).to.eql([4, 8]); }); }); @@ -225,31 +225,31 @@ describe('ol.structs.Buffer', function() { it('allows multiple adds and removes', function() { var b = new ol.structs.Buffer(new Array(8), 0); expect(b.add([0, 1])).to.be(0); - expect(b.getArray()).to.equalArray([0, 1, NaN, NaN, NaN, NaN, NaN, NaN]); + expect(b.getArray()).to.eql([0, 1, NaN, NaN, NaN, NaN, NaN, NaN]); expect(b.getCount()).to.be(2); expect(b.add([2, 3, 4, 5])).to.be(2); - expect(b.getArray()).to.equalArray([0, 1, 2, 3, 4, 5, NaN, NaN]); + expect(b.getArray()).to.eql([0, 1, 2, 3, 4, 5, NaN, NaN]); expect(b.getCount()).to.be(6); expect(b.add([6, 7])).to.be(6); - expect(b.getArray()).to.equalArray([0, 1, 2, 3, 4, 5, 6, 7]); + expect(b.getArray()).to.eql([0, 1, 2, 3, 4, 5, 6, 7]); expect(b.getCount()).to.be(8); b.remove(2, 2); - expect(b.getArray()).to.equalArray([0, 1, NaN, NaN, 4, 5, 6, 7]); + expect(b.getArray()).to.eql([0, 1, NaN, NaN, 4, 5, 6, 7]); expect(b.getCount()).to.be(6); expect(b.add([8, 9])).to.be(2); - expect(b.getArray()).to.equalArray([0, 1, 8, 9, 4, 5, 6, 7]); + expect(b.getArray()).to.eql([0, 1, 8, 9, 4, 5, 6, 7]); expect(b.getCount()).to.be(8); b.remove(1, 1); - expect(b.getArray()).to.equalArray([0, NaN, 8, 9, 4, 5, 6, 7]); + expect(b.getArray()).to.eql([0, NaN, 8, 9, 4, 5, 6, 7]); expect(b.getCount()).to.be(7); b.remove(4, 4); - expect(b.getArray()).to.equalArray([0, NaN, 8, 9, NaN, NaN, NaN, NaN]); + expect(b.getArray()).to.eql([0, NaN, 8, 9, NaN, NaN, NaN, NaN]); expect(b.getCount()).to.be(3); expect(b.add([10, 11, 12])).to.be(4); - expect(b.getArray()).to.equalArray([0, NaN, 8, 9, 10, 11, 12, NaN]); + expect(b.getArray()).to.eql([0, NaN, 8, 9, 10, 11, 12, NaN]); expect(b.getCount()).to.be(6); expect(b.add([13])).to.be(1); - expect(b.getArray()).to.equalArray([0, 13, 8, 9, 10, 11, 12, NaN]); + expect(b.getArray()).to.eql([0, 13, 8, 9, 10, 11, 12, NaN]); expect(b.getCount()).to.be(7); }); diff --git a/test/spec/ol/structs/integerset.test.js b/test/spec/ol/structs/integerset.test.js index ec4477ef5c..8cd1728b64 100644 --- a/test/spec/ol/structs/integerset.test.js +++ b/test/spec/ol/structs/integerset.test.js @@ -20,7 +20,7 @@ describe('ol.structs.IntegerSet', function() { it('constructs with a valid array', function() { var is = new ol.structs.IntegerSet([0, 2, 4, 6]); expect(is).to.be.an(ol.structs.IntegerSet); - expect(is.getArray()).to.equalArray([0, 2, 4, 6]); + expect(is.getArray()).to.eql([0, 2, 4, 6]); }); it('throws an exception with an odd number of elements', function() { @@ -50,7 +50,7 @@ describe('ol.structs.IntegerSet', function() { it('creates a new element', function() { is.addRange(0, 2); - expect(is.getArray()).to.equalArray([0, 2]); + expect(is.getArray()).to.eql([0, 2]); }); }); @@ -79,7 +79,7 @@ describe('ol.structs.IntegerSet', function() { var callback = sinon.spy(); is.forEachRangeInverted(0, 8, callback); expect(callback.calledOnce).to.be(true); - expect(callback.args[0]).to.equalArray([0, 8]); + expect(callback.args[0]).to.eql([0, 8]); }); }); @@ -145,52 +145,52 @@ describe('ol.structs.IntegerSet', function() { it('inserts before the first element', function() { is.addRange(0, 2); - expect(is.getArray()).to.equalArray([0, 2, 4, 6, 8, 10, 12, 14]); + expect(is.getArray()).to.eql([0, 2, 4, 6, 8, 10, 12, 14]); }); it('extends the first element to the left', function() { is.addRange(0, 4); - expect(is.getArray()).to.equalArray([0, 6, 8, 10, 12, 14]); + expect(is.getArray()).to.eql([0, 6, 8, 10, 12, 14]); }); it('extends the first element to the right', function() { is.addRange(6, 7); - expect(is.getArray()).to.equalArray([4, 7, 8, 10, 12, 14]); + expect(is.getArray()).to.eql([4, 7, 8, 10, 12, 14]); }); it('merges the first two elements', function() { is.addRange(6, 8); - expect(is.getArray()).to.equalArray([4, 10, 12, 14]); + expect(is.getArray()).to.eql([4, 10, 12, 14]); }); it('extends middle elements to the left', function() { is.addRange(7, 8); - expect(is.getArray()).to.equalArray([4, 6, 7, 10, 12, 14]); + expect(is.getArray()).to.eql([4, 6, 7, 10, 12, 14]); }); it('extends middle elements to the right', function() { is.addRange(10, 11); - expect(is.getArray()).to.equalArray([4, 6, 8, 11, 12, 14]); + expect(is.getArray()).to.eql([4, 6, 8, 11, 12, 14]); }); it('merges the last two elements', function() { is.addRange(10, 12); - expect(is.getArray()).to.equalArray([4, 6, 8, 14]); + expect(is.getArray()).to.eql([4, 6, 8, 14]); }); it('extends the last element to the left', function() { is.addRange(11, 12); - expect(is.getArray()).to.equalArray([4, 6, 8, 10, 11, 14]); + expect(is.getArray()).to.eql([4, 6, 8, 10, 11, 14]); }); it('extends the last element to the right', function() { is.addRange(14, 15); - expect(is.getArray()).to.equalArray([4, 6, 8, 10, 12, 15]); + expect(is.getArray()).to.eql([4, 6, 8, 10, 12, 15]); }); it('inserts after the last element', function() { is.addRange(16, 18); - expect(is.getArray()).to.equalArray([4, 6, 8, 10, 12, 14, 16, 18]); + expect(is.getArray()).to.eql([4, 6, 8, 10, 12, 14, 16, 18]); }); }); @@ -239,9 +239,9 @@ describe('ol.structs.IntegerSet', function() { is.forEachRange(callback); expect(callback).to.be.called(); expect(callback.calledThrice).to.be(true); - expect(callback.args[0]).to.equalArray([4, 6]); - expect(callback.args[1]).to.equalArray([8, 10]); - expect(callback.args[2]).to.equalArray([12, 14]); + expect(callback.args[0]).to.eql([4, 6]); + expect(callback.args[1]).to.eql([8, 10]); + expect(callback.args[2]).to.eql([12, 14]); }); }); @@ -252,10 +252,10 @@ describe('ol.structs.IntegerSet', function() { var callback = sinon.spy(); is.forEachRangeInverted(0, 16, callback); expect(callback.callCount).to.be(4); - expect(callback.args[0]).to.equalArray([0, 4]); - expect(callback.args[1]).to.equalArray([6, 8]); - expect(callback.args[2]).to.equalArray([10, 12]); - expect(callback.args[3]).to.equalArray([14, 16]); + expect(callback.args[0]).to.eql([0, 4]); + expect(callback.args[1]).to.eql([6, 8]); + expect(callback.args[2]).to.eql([10, 12]); + expect(callback.args[3]).to.eql([14, 16]); }); }); @@ -334,57 +334,57 @@ describe('ol.structs.IntegerSet', function() { it('removes the first part of the first element', function() { is.removeRange(4, 5); - expect(is.getArray()).to.equalArray([5, 6, 8, 10, 12, 14]); + expect(is.getArray()).to.eql([5, 6, 8, 10, 12, 14]); }); it('removes the last part of the first element', function() { is.removeRange(5, 6); - expect(is.getArray()).to.equalArray([4, 5, 8, 10, 12, 14]); + expect(is.getArray()).to.eql([4, 5, 8, 10, 12, 14]); }); it('removes the first element', function() { is.removeRange(4, 6); - expect(is.getArray()).to.equalArray([8, 10, 12, 14]); + expect(is.getArray()).to.eql([8, 10, 12, 14]); }); it('removes the first part of a middle element', function() { is.removeRange(8, 9); - expect(is.getArray()).to.equalArray([4, 6, 9, 10, 12, 14]); + expect(is.getArray()).to.eql([4, 6, 9, 10, 12, 14]); }); it('removes the last part of a middle element', function() { is.removeRange(9, 10); - expect(is.getArray()).to.equalArray([4, 6, 8, 9, 12, 14]); + expect(is.getArray()).to.eql([4, 6, 8, 9, 12, 14]); }); it('removes a middle element', function() { is.removeRange(8, 10); - expect(is.getArray()).to.equalArray([4, 6, 12, 14]); + expect(is.getArray()).to.eql([4, 6, 12, 14]); }); it('removes the first part of the last element', function() { is.removeRange(12, 13); - expect(is.getArray()).to.equalArray([4, 6, 8, 10, 13, 14]); + expect(is.getArray()).to.eql([4, 6, 8, 10, 13, 14]); }); it('removes the last part of the last element', function() { is.removeRange(13, 14); - expect(is.getArray()).to.equalArray([4, 6, 8, 10, 12, 13]); + expect(is.getArray()).to.eql([4, 6, 8, 10, 12, 13]); }); it('removes the last element', function() { is.removeRange(12, 14); - expect(is.getArray()).to.equalArray([4, 6, 8, 10]); + expect(is.getArray()).to.eql([4, 6, 8, 10]); }); it('can remove multiple ranges near the start', function() { is.removeRange(3, 11); - expect(is.getArray()).to.equalArray([12, 14]); + expect(is.getArray()).to.eql([12, 14]); }); it('can remove multiple ranges near the start', function() { is.removeRange(7, 15); - expect(is.getArray()).to.equalArray([4, 6]); + expect(is.getArray()).to.eql([4, 6]); }); it('throws an exception when passed an invalid range', function() { @@ -459,29 +459,29 @@ describe('ol.structs.IntegerSet', function() { it('removing an empty range has no effect', function() { is.removeRange(0, 0); - expect(is.getArray()).to.equalArray( + expect(is.getArray()).to.eql( [0, 1, 2, 4, 5, 8, 9, 12, 13, 15, 16, 17]); }); it('can remove elements from the middle of range', function() { is.removeRange(6, 7); - expect(is.getArray()).to.equalArray( + expect(is.getArray()).to.eql( [0, 1, 2, 4, 5, 6, 7, 8, 9, 12, 13, 15, 16, 17]); }); it('can remove multiple ranges', function() { is.removeRange(2, 12); - expect(is.getArray()).to.equalArray([0, 1, 13, 15, 16, 17]); + expect(is.getArray()).to.eql([0, 1, 13, 15, 16, 17]); }); it('can remove multiple ranges and reduce others', function() { is.removeRange(0, 10); - expect(is.getArray()).to.equalArray([10, 12, 13, 15, 16, 17]); + expect(is.getArray()).to.eql([10, 12, 13, 15, 16, 17]); }); it('can remove all ranges', function() { is.removeRange(0, 18); - expect(is.getArray()).to.equalArray([]); + expect(is.getArray()).to.eql([]); }); }); @@ -556,7 +556,7 @@ describe('ol.structs.IntegerSet', function() { addStop = addStart + goog.math.randomInt(16); is.addRange(addStart, addStop); sis.addRange(addStart, addStop); - expect(is.getArray()).to.equalArray(sis.getArray()); + expect(is.getArray()).to.eql(sis.getArray()); } }); @@ -569,7 +569,7 @@ describe('ol.structs.IntegerSet', function() { removeStop = removeStart + goog.math.randomInt(16); is.removeRange(removeStart, removeStop); sis.removeRange(removeStart, removeStop); - expect(is.getArray()).to.equalArray(sis.getArray()); + expect(is.getArray()).to.eql(sis.getArray()); } }); @@ -585,7 +585,7 @@ describe('ol.structs.IntegerSet', function() { is.removeRange(start, stop); sis.removeRange(start, stop); } - expect(is.getArray()).to.equalArray(sis.getArray()); + expect(is.getArray()).to.eql(sis.getArray()); } }); @@ -605,7 +605,7 @@ describe('ol.structs.IntegerSet', function() { is.clear(); sis.clear(); } - expect(is.getArray()).to.equalArray(sis.getArray()); + expect(is.getArray()).to.eql(sis.getArray()); } }); diff --git a/test/spec/ol/structs/priorityqueue.test.js b/test/spec/ol/structs/priorityqueue.test.js index c9d7b27cd1..b80350294f 100644 --- a/test/spec/ol/structs/priorityqueue.test.js +++ b/test/spec/ol/structs/priorityqueue.test.js @@ -32,8 +32,8 @@ describe('ol.structs.PriorityQueue', function() { expect(function() { pq.assertValid(); }).not.to.throwException(); - expect(pq.elements_).to.equalArray([0]); - expect(pq.priorities_).to.equalArray([0]); + expect(pq.elements_).to.eql([0]); + expect(pq.priorities_).to.eql([0]); }); it('maintains the pq property while elements are enqueued', function() { diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index ae3e583a84..2c87049f17 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -73,7 +73,7 @@ describe('ol.TileUrlFunction', function() { ]); var tileUrl1 = tileUrl(new ol.TileCoord(1, 0, 0)); var tileUrl2 = tileUrl(new ol.TileCoord(1, 0, 1)); - expect(tileUrl1).not.to.eql(tileUrl2); + expect(tileUrl1).not.to.be(tileUrl2); expect(tileUrl(null)).to.be(undefined); }); });