From 6910c471bf5467d43b717a5ea223e1a19d3a35e0 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 4 Jul 2016 16:46:34 +0200 Subject: [PATCH] Add unit tests for ol.View.createCenterConstraint --- test/spec/ol/view.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/spec/ol/view.test.js b/test/spec/ol/view.test.js index b891b293aa..b7bfbe1158 100644 --- a/test/spec/ol/view.test.js +++ b/test/spec/ol/view.test.js @@ -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() {