Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test improvements #362

Merged
merged 2 commits into from Mar 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/spec/ol/collection.test.js
Expand Up @@ -80,7 +80,7 @@ describe('ol.collection', function() {
describe('on an empty collection', function() {
it('does not call the callback', function() {
collection.forEach(cb);
expect(cb.called).to.not.be.ok();
expect(cb).to.not.be.called();
});
});
describe('on a non-empty collection', function() {
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('ol.collection', function() {
var cb = sinon.spy();
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).to.eql(1);
expect(cb.called).to.be.ok();
expect(cb).to.be.called();
expect(cb.lastCall.args[0].elem).to.eql(1);
});
it('does not remove more than one matching element', function() {
Expand Down Expand Up @@ -206,21 +206,21 @@ describe('ol.collection', function() {
describe('insertAt', function() {
it('triggers length_changed event', function() {
collection.insertAt(2, 3);
expect(cb.called).to.be.ok();
expect(cb).to.be.called();
});
});

describe('removeAt', function() {
it('triggers length_changed event', function() {
collection.removeAt(0);
expect(cb.called).to.be.ok();
expect(cb).to.be.called();
});
});

describe('setAt', function() {
it('does not trigger length_changed event', function() {
collection.setAt(1, 1);
expect(cb.called).to.not.be.ok();
expect(cb).to.not.be.called();
});
});
});
Expand Down
10 changes: 5 additions & 5 deletions test/spec/ol/layer/vectorlayer.test.js
Expand Up @@ -56,15 +56,15 @@ describe('ol.layer.Vector', function() {
it('can filter by geometry type using its GeometryType index', function() {
sinon.spy(geomFilter, 'applies');
var lineStrings = layer.getFeatures(geomFilter);
expect(geomFilter.applies.called).to.not.be.ok();
expect(geomFilter.applies).to.not.be.called();
expect(lineStrings.length).to.eql(4);
expect(lineStrings).to.contain(features[4]);
});

it('can filter by extent using its RTree', function() {
sinon.spy(extentFilter, 'applies');
var subset = layer.getFeatures(extentFilter);
expect(extentFilter.applies.called).to.not.be.ok();
expect(extentFilter.applies).to.not.be.called();
expect(subset.length).to.eql(4);
expect(subset).not.to.contain(features[7]);
});
Expand All @@ -78,8 +78,8 @@ describe('ol.layer.Vector', function() {
sinon.spy(filter2, 'applies');
var subset1 = layer.getFeatures(filter1);
var subset2 = layer.getFeatures(filter2);
expect(filter1.applies.called).to.not.be.ok();
expect(filter2.applies.called).to.not.be.ok();
expect(filter1.applies).to.not.be.called();
expect(filter2.applies).to.not.be.called();
expect(subset1.length).to.eql(0);
expect(subset2.length).to.eql(0);
});
Expand All @@ -89,7 +89,7 @@ describe('ol.layer.Vector', function() {
ol.filter.LogicalOperator.OR);
sinon.spy(filter, 'applies');
var subset = layer.getFeatures(filter);
expect(filter.applies.called).to.be.ok();
expect(filter.applies).to.be.called();
expect(subset.length).to.eql(8);
});

Expand Down
2 changes: 1 addition & 1 deletion test/spec/ol/map.test.js
Expand Up @@ -198,7 +198,7 @@ describe('ol.Map', function() {
// confirm that the center is somewhere between origin and destination
// after a short delay
setTimeout(function() {
expect(o.callback.called).to.be.ok();
expect(o.callback).to.be.called();
var loc = map.getView().getCenter();
expect(loc.x).not.to.eql(origin.x);
expect(loc.y).not.to.eql(origin.y);
Expand Down
32 changes: 16 additions & 16 deletions test/spec/ol/object.test.js
Expand Up @@ -116,17 +116,17 @@ describe('ol.Object', function() {

it('dispatches events', function() {
o.notify('k');
expect(listener1.called).to.be.ok();
expect(listener1).to.be.called();
});

it('dispatches generic change events to bound objects', function() {
o.notify('k');
expect(listener2.called).to.be.ok();
expect(listener2).to.be.called();
});

it('dispatches events to bound objects', function() {
o.notify('k');
expect(listener3.called).to.be.ok();
expect(listener3).to.be.called();
});
});

Expand All @@ -149,33 +149,33 @@ describe('ol.Object', function() {

it('dispatches events to object', function() {
o.set('k', 1);
expect(listener1.called).to.be.ok();
expect(listener1).to.be.called();

expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).to.eql(['k']);
});

it('dispatches generic change events to object', function() {
o.set('k', 1);
expect(listener2.called).to.be.ok();
expect(listener2).to.be.called();
});

it('dispatches events to bound object', function() {
o.set('k', 1);
expect(listener3.called).to.be.ok();
expect(listener3).to.be.called();
});

it('dispatches events to object bound to', function() {
o2.set('k', 2);
expect(listener1.called).to.be.ok();
expect(listener1).to.be.called();

expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).to.eql(['k']);
});

it('dispatches generic change events to object bound to', function() {
o2.set('k', 2);
expect(listener2.called).to.be.ok();
expect(listener2).to.be.called();
});
});

Expand Down Expand Up @@ -300,8 +300,8 @@ describe('ol.Object', function() {
expect(o.get('k2')).to.be(undefined);
expect(o2.get('k2')).to.eql(1);
expect(o2.get('k1')).to.be(undefined);
expect(listener1.called).to.be.ok();
expect(listener2.called).to.be.ok();
expect(listener1).to.be.called();
expect(listener2).to.be.called();

expect(o.getKeys()).to.eql(['k1']);
expect(o2.getKeys()).to.eql(['k2']);
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('ol.Object', function() {
it('does not call the setter', function() {
o.set('x', 1);
expect(o.get('x')).to.eql(1);
expect(o.setX.called).to.not.be.ok();
expect(o.setX).to.not.be.called();

expect(o.getKeys()).to.eql(['x']);
});
Expand All @@ -403,7 +403,7 @@ describe('ol.Object', function() {
var o2 = new ol.Object();
o2.bindTo('x', o);
o2.set('x', 1);
expect(o.setX.called).to.be.ok();
expect(o.setX).to.be.called();
expect(o.get('x')).to.eql(1);

expect(o.getKeys()).to.eql(['x']);
Expand All @@ -423,7 +423,7 @@ describe('ol.Object', function() {
describe('without bind', function() {
it('does not call the getter', function() {
expect(o.get('x')).to.be(undefined);
expect(o.getX.called).to.not.be.ok();
expect(o.getX).to.not.be.called();
});
});

Expand All @@ -432,7 +432,7 @@ describe('ol.Object', function() {
var o2 = new ol.Object();
o2.bindTo('x', o);
expect(o2.get('x')).to.eql(1);
expect(o.getX.called).to.be.ok();
expect(o.getX).to.be.called();

expect(o.getKeys()).to.eql([]);
expect(o2.getKeys()).to.eql(['x']);
Expand Down Expand Up @@ -467,8 +467,8 @@ describe('ol.Object', function() {

it('dispatches the expected event', function() {
o.set('K', 1);
expect(listener1.called).to.be.ok();
expect(listener2.called).to.not.be.ok();
expect(listener1).to.be.called();
expect(listener2).to.not.be.called();

expect(o.getKeys()).to.eql(['K']);
});
Expand Down
3 changes: 0 additions & 3 deletions test/spec/ol/rectangle.test.js
Expand Up @@ -17,9 +17,6 @@ describe('ol.Rectangle', function() {

beforeEach(function() {
rectangle1 = new ol.Rectangle(50, 50, 100, 100);
expect.Assertion.prototype.intersectWith = function(other) {
return this.obj.intersects(other);
};
});

it('returns the expected value', function() {
Expand Down
9 changes: 9 additions & 0 deletions test/test-extensions.js
Expand Up @@ -24,6 +24,15 @@ expect.Assertion.prototype.roughlyEqual = function(other, tol) {
};


expect.Assertion.prototype.intersectWith = function(other) {
return this.obj.intersects(other);
};


expect.Assertion.prototype.called = function() {
return this.obj.called;
};


// helper functions for async testing
(function(global) {
Expand Down