Add tests for ol.source.ImageWMS#getGetFeatureInfoUrl
This commit is contained in:
@@ -3,22 +3,22 @@ goog.provide('ol.test.source.ImageWMS');
|
|||||||
|
|
||||||
describe('ol.source.ImageWMS', function() {
|
describe('ol.source.ImageWMS', function() {
|
||||||
|
|
||||||
describe('#getImage', function() {
|
var extent, pixelRatio, options, projection, resolution;
|
||||||
|
beforeEach(function() {
|
||||||
|
extent = [10, 20, 30, 40];
|
||||||
|
pixelRatio = 1;
|
||||||
|
projection = ol.proj.get('EPSG:4326');
|
||||||
|
resolution = 0.1;
|
||||||
|
options = {
|
||||||
|
params: {
|
||||||
|
'LAYERS': 'layer'
|
||||||
|
},
|
||||||
|
ratio: 1,
|
||||||
|
url: 'http://example.com/wms'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
var extent, pixelRatio, options, projection, resolution;
|
describe('#getImage', function() {
|
||||||
beforeEach(function() {
|
|
||||||
extent = [10, 20, 30, 40];
|
|
||||||
pixelRatio = 1;
|
|
||||||
projection = ol.proj.get('EPSG:4326');
|
|
||||||
resolution = 0.1;
|
|
||||||
options = {
|
|
||||||
params: {
|
|
||||||
'LAYERS': 'layer'
|
|
||||||
},
|
|
||||||
ratio: 1,
|
|
||||||
url: 'http://example.com/wms'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the expected image URL', function() {
|
it('returns the expected image URL', function() {
|
||||||
var source = new ol.source.ImageWMS(options);
|
var source = new ol.source.ImageWMS(options);
|
||||||
@@ -136,6 +136,67 @@ describe('ol.source.ImageWMS', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getGetFeatureInfo', function() {
|
||||||
|
|
||||||
|
it('returns the expected GetFeatureInfo URL', function() {
|
||||||
|
var source = new ol.source.ImageWMS(options);
|
||||||
|
source.getImage(extent, resolution, pixelRatio, projection);
|
||||||
|
var url = source.getGetFeatureInfoUrl(
|
||||||
|
[20, 30], resolution, projection,
|
||||||
|
{INFO_FORMAT: 'text/plain'});
|
||||||
|
var uri = new goog.Uri(url);
|
||||||
|
expect(uri.getScheme()).to.be('http');
|
||||||
|
expect(uri.getDomain()).to.be('example.com');
|
||||||
|
expect(uri.getPath()).to.be('/wms');
|
||||||
|
var queryData = uri.getQueryData();
|
||||||
|
expect(queryData.get('BBOX')).to.be('20,10,40,30');
|
||||||
|
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||||
|
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||||
|
expect(queryData.get('HEIGHT')).to.be('200');
|
||||||
|
expect(queryData.get('I')).to.be('100');
|
||||||
|
expect(queryData.get('J')).to.be('100');
|
||||||
|
expect(queryData.get('LAYERS')).to.be('layer');
|
||||||
|
expect(queryData.get('QUERY_LAYERS')).to.be('layer');
|
||||||
|
expect(queryData.get('REQUEST')).to.be('GetFeatureInfo');
|
||||||
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
|
expect(queryData.get('SRS')).to.be(undefined);
|
||||||
|
expect(queryData.get('STYLES')).to.be('');
|
||||||
|
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||||
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
|
expect(queryData.get('WIDTH')).to.be('200');
|
||||||
|
expect(uri.getFragment()).to.be.empty();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets the QUERY_LAYERS param as expected', function() {
|
||||||
|
var source = new ol.source.ImageWMS(options);
|
||||||
|
source.getImage(extent, resolution, pixelRatio, projection);
|
||||||
|
var url = source.getGetFeatureInfoUrl(
|
||||||
|
[20, 30], resolution, projection,
|
||||||
|
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||||
|
var uri = new goog.Uri(url);
|
||||||
|
expect(uri.getScheme()).to.be('http');
|
||||||
|
expect(uri.getDomain()).to.be('example.com');
|
||||||
|
expect(uri.getPath()).to.be('/wms');
|
||||||
|
var queryData = uri.getQueryData();
|
||||||
|
expect(queryData.get('BBOX')).to.be('20,10,40,30');
|
||||||
|
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||||
|
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||||
|
expect(queryData.get('HEIGHT')).to.be('200');
|
||||||
|
expect(queryData.get('I')).to.be('100');
|
||||||
|
expect(queryData.get('J')).to.be('100');
|
||||||
|
expect(queryData.get('LAYERS')).to.be('layer');
|
||||||
|
expect(queryData.get('QUERY_LAYERS')).to.be('foo,bar');
|
||||||
|
expect(queryData.get('REQUEST')).to.be('GetFeatureInfo');
|
||||||
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
|
expect(queryData.get('SRS')).to.be(undefined);
|
||||||
|
expect(queryData.get('STYLES')).to.be('');
|
||||||
|
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||||
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
|
expect(queryData.get('WIDTH')).to.be('200');
|
||||||
|
expect(uri.getFragment()).to.be.empty();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user