Extend expect.js rather than modify the source

This commit is contained in:
Tim Schaub
2014-07-06 12:40:03 -06:00
parent d8ca8e7341
commit 93716fc7f0
7 changed files with 281 additions and 1484 deletions

View File

@@ -3,6 +3,21 @@ goog.provide('ol.test.expect.js');
describe('expect.js', function() {
describe('arreqlNaN', function() {
it('considers NaN in array to be equal', function() {
expect([1, NaN, 2]).to.arreqlNaN([1, NaN, 2]);
expect([1, NaN, 2]).not.to.arreqlNaN([1, 1.5, 2]);
});
it('allows a mix of number and string', function() {
expect([1, NaN, 'foo']).to.arreqlNaN([1, NaN, 'foo']);
expect([1, NaN, 'foo']).not.to.arreqlNaN([1, NaN, 'bar']);
expect([1, NaN]).not.to.arreqlNaN([1, 'foo']);
});
});
describe('roughlyEqual', function() {
it('can tell the difference between 1 and 3', function() {

View File

@@ -260,31 +260,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.eql([0, 1, NaN, NaN, NaN, NaN, NaN, NaN]);
expect(b.getArray()).to.arreqlNaN([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.eql([0, 1, 2, 3, 4, 5, NaN, NaN]);
expect(b.getArray()).to.arreqlNaN([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.eql([0, 1, 2, 3, 4, 5, 6, 7]);
expect(b.getCount()).to.be(8);
b.remove(2, 2);
expect(b.getArray()).to.eql([0, 1, NaN, NaN, 4, 5, 6, 7]);
expect(b.getArray()).to.arreqlNaN([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.eql([0, 1, 8, 9, 4, 5, 6, 7]);
expect(b.getCount()).to.be(8);
b.remove(1, 1);
expect(b.getArray()).to.eql([0, NaN, 8, 9, 4, 5, 6, 7]);
expect(b.getArray()).to.arreqlNaN([0, NaN, 8, 9, 4, 5, 6, 7]);
expect(b.getCount()).to.be(7);
b.remove(4, 4);
expect(b.getArray()).to.eql([0, NaN, 8, 9, NaN, NaN, NaN, NaN]);
expect(b.getArray()).to.arreqlNaN([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.eql([0, NaN, 8, 9, 10, 11, 12, NaN]);
expect(b.getArray()).to.arreqlNaN([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.eql([0, 13, 8, 9, 10, 11, 12, NaN]);
expect(b.getArray()).to.arreqlNaN([0, 13, 8, 9, 10, 11, 12, NaN]);
expect(b.getCount()).to.be(7);
});