Skip to content

Commit

Permalink
fix metadata test + test metadata if url is using subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Guilhaudin committed Dec 30, 2017
1 parent dd85804 commit 1e96460
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions spec/Layers/TiledMapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe('L.esri.TiledMapLayer', function () {
}

var url = 'http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer';
var subdomainsUrl = 'http://{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer';
var subdomainsArray = ['server', 'services'];
var layer;
var server;
var map;
Expand Down Expand Up @@ -130,19 +132,38 @@ describe('L.esri.TiledMapLayer', function () {
});

it('should display a metadata attribution if one is present and no attribution option was passed', function () {
var copyrightText;
server.respondWith('GET', 'http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/?f=json', JSON.stringify({
copyrightText: 'foo',
spatialReference: {
wkid: 102100,
latestWkid: 3857
}
}));

layer = L.esri.tiledMapLayer({
url: url
}).addTo(map);

layer.on('load', function () {
layer.metadata(function (err, meta) {
if (meta && meta.hasOwnProperty(copyrightText)) {
copyrightText = meta.copyrightText;
expect(map.attributionControl._container.innerHTML).to.contain(copyrightText);
}
});
});
server.respond();
expect(map.attributionControl._container.innerHTML).to.contain('foo');
});

it('should display a metadata attribution if one is present and no attribution option was passed and url is defined with subdomains', function () {
server.respondWith('GET', 'http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/?f=json', JSON.stringify({
copyrightText: 'foo',
spatialReference: {
wkid: 102100,
latestWkid: 3857
}
}));

layer = L.esri.tiledMapLayer({
url: subdomainsUrl,
subdomains: subdomainsArray
}).addTo(map);

server.respond();
expect(map.attributionControl._container.innerHTML).to.contain('foo');
});
});
/* eslint-enable handle-callback-err */

0 comments on commit 1e96460

Please sign in to comment.