From d7b13ab09f107d2cbe042acebe6f062febad4098 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 14 Mar 2013 14:49:41 +0100 Subject: [PATCH 1/2] Add test for array equality Hilariously, expect.js does not have one. --- test/test-extensions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test-extensions.js b/test/test-extensions.js index abb0ab0ea7..333bce0cb9 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -34,6 +34,11 @@ expect.Assertion.prototype.called = function() { }; +expect.Assertion.prototype.equalArray = function(other) { + return goog.array.equals(this.obj, other); +}; + + // helper functions for async testing (function(global) { From 7222464426112b4ebdb6f885bcd0c0e3babb09a7 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 14 Mar 2013 14:50:23 +0100 Subject: [PATCH 2/2] Don't use goog.array in ol.Collection tests --- test/spec/ol/collection.test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/spec/ol/collection.test.js b/test/spec/ol/collection.test.js index 77d746aef2..faa9eacf89 100644 --- a/test/spec/ol/collection.test.js +++ b/test/spec/ol/collection.test.js @@ -10,7 +10,7 @@ describe('ol.collection', function() { describe('create an empty collection', function() { it('creates an empty collection', function() { expect(collection.getLength()).to.eql(0); - expect(goog.array.equals(collection.getArray(), [])).to.be.ok(); + expect(collection.getArray()).to.be.empty(); expect(collection.getAt(0)).to.be(undefined); }); }); @@ -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(goog.array.equals(collection.getArray(), [1])).to.be.ok(); + expect(collection.getArray()).to.equalArray([1]); expect(collection.getAt(0)).to.eql(1); }); }); @@ -39,7 +39,7 @@ describe('ol.collection', function() { collection.push(1); collection.pop(); expect(collection.getLength()).to.eql(0); - expect(goog.array.equals(collection.getArray(), [])).to.be.ok(); + expect(collection.getArray()).to.be.empty(); expect(collection.getAt(0)).to.be(undefined); }); }); @@ -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(goog.array.equals(collection.getArray(), [1, 2])).to.be.ok(); + expect(collection.getArray()).to.equalArray([1, 2]); expect(collection.getAt(0)).to.eql(1); expect(collection.getAt(1)).to.eql(2); }); @@ -275,6 +275,5 @@ describe('ol.collection', function() { }); -goog.require('goog.array'); goog.require('ol.Collection'); goog.require('ol.CollectionEventType');