Merge pull request #5561 from fredj/test_centerConstraint

Add unit tests for ol.View.createCenterConstraint
This commit is contained in:
Frédéric Junod
2016-07-05 09:13:34 +02:00
committed by GitHub

View File

@@ -21,6 +21,32 @@ describe('ol.View', function() {
describe('create constraints', function() {
describe('create center constraint', function() {
describe('with no options', function() {
it('gives a correct center constraint function', function() {
var options = {};
var fn = ol.View.createCenterConstraint_(options);
expect(fn([0, 0])).to.eql([0, 0]);
expect(fn(undefined)).to.eql(undefined);
expect(fn([42, -100])).to.eql([42, -100]);
});
});
describe('with extent option', function() {
it('gives a correct center constraint function', function() {
var options = {
extent: [0, 0, 1, 1]
};
var fn = ol.View.createCenterConstraint_(options);
expect(fn([0, 0])).to.eql([0, 0]);
expect(fn([-10, 0])).to.eql([0, 0]);
expect(fn([100, 100])).to.eql([1, 1]);
});
});
});
describe('create resolution constraint', function() {
describe('with no options', function() {