Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Last active December 20, 2015 06:49
Show Gist options
  • Save dbouwman/6088911 to your computer and use it in GitHub Desktop.
Save dbouwman/6088911 to your computer and use it in GitHub Desktop.
Example of a real test using the helper
describe('the map configurator', function(){
it('should add specified layers as dynamic services', function(){
var data = getJSONFixture('layers-only.json');
var flag,localMap,divId = 'map-layers-test';
runs(function(){
var flagCallback = function(result){
flag = true;
};
var actionCallback = function(map){
localMap = map;
app.MapConfigurator.load(map,data,flagCallback);
};
createTestMap( divId , actionCallback );
});
waitsFor(function(){
return flag;
}, 'the call to setup the webmap', 5000);
runs( function(){
//assertions
expect( localMap.layerIds.length ).toBe(3);
//get the layer
var layer = localMap.getLayer(data.layers[0].id);
//check that the id was set by ensuring the the returned object is defined
expect(layer).toBeDefined();
//check that it's url matches what's in the test data
expect(layer.url).toBe(data.layers[0].url);
expect(layer.visibleLayers).toBe(data.layers[0].visibleLayers);
expect(layer.opacity).toBe(data.layers[0].opacity);
//same for the second layer
layer = localMap.getLayer(data.layers[1].id);
expect(layer).toBeDefined();
expect(layer.url).toBe(data.layers[1].url);
expect(layer.visibleLayers).toBe(data.layers[1].visibleLayers);
expect(layer.opacity).toBe(data.layers[1].opacity);
//clean up
localMap.destroy();//kill the map object
$('#' + divId).remove();//kill from the dom
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment