Add unit tests for ol.View.createCenterConstraint
This commit is contained in:
@@ -21,6 +21,32 @@ describe('ol.View', function() {
|
|||||||
|
|
||||||
describe('create constraints', 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('create resolution constraint', function() {
|
||||||
|
|
||||||
describe('with no options', function() {
|
describe('with no options', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user