Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgravois committed Apr 28, 2015
1 parent e28f642 commit 1b1271c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/Layers/FeatureLayer/FeatureLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('L.esri.Layers.FeatureLayer', function () {
layer.addLayers([1]);
});

it('should readd features back to a map', function(){
it('should read features back to a map', function(){
map.removeLayer(layer.getFeature(1));

layer.createLayers([{
Expand Down
24 changes: 24 additions & 0 deletions spec/Layers/FeatureLayer/FeatureManagerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,30 @@ describe('L.esri.Layers.FeatureManager', function () {
server.respond();
});

it('should wrap the removeFeatures method on the underlying service', function(done){
server.respondWith('POST', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/deleteFeatures', JSON.stringify({
'deleteResults' : [{
'objectId' : 1,
'success' : true
},{
'objectId' : 2,
'success' : true
}]
}));

layer.deleteFeatures([1,2], function(error, response){
expect(layer.removeLayers).to.have.been.calledWith([1]);
expect(layer.removeLayers).to.have.been.calledWith([2]);
expect(response[1]).to.deep.equal({
'objectId': 2,
'success': true
});
done();
});

server.respond();
});

it('should support generalizing geometries', function(){
server.respondWith('GET', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=1%3D1&outSr=4326&outFields=*&inSr=4326&geometry=%7B%22xmin%22%3A-122.6953125%2C%22ymin%22%3A45.521743896993634%2C%22xmax%22%3A-122.6513671875%2C%22ymax%22%3A45.55252525134013%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&maxAllowableOffset=0.00004291534423829546&f=json', JSON.stringify({
fields: fields,
Expand Down
30 changes: 29 additions & 1 deletion spec/Services/FeatureLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('L.esri.Services.FeatureLayer', function () {
}));
});

it('should be able to remove features from the layer', function(){
it('should be able to remove a feature from the layer', function(){
var callback = sinon.spy();

service.deleteFeature(1, callback);
Expand Down Expand Up @@ -163,4 +163,32 @@ describe('L.esri.Services.FeatureLayer', function () {
}]
}));
});

it('should be able to remove features from the layer', function(){
var callback = sinon.spy();

service.deleteFeatures([1,2], callback);

requests[0].respond(200, { 'Content-Type': 'text/plain; charset=utf-8' }, JSON.stringify({
'deleteResults' : [{
'objectId' : 1,
'success' : true
},{
'objectId' : 2,
'success' : true
}]
}));

var requestBody = window.decodeURIComponent(requests[0].requestBody);

expect(requestBody).to.equal('objectIds=1,2&f=json');

callback.should.have.been.calledWith(undefined, [{
'objectId' : 1,
'success' : true
},{
'objectId' : 2,
'success' : true
}]);
});
});

0 comments on commit 1b1271c

Please sign in to comment.