Skip to content

Commit

Permalink
Merge pull request #80 from fga-gpp-mds/US14_LinkRespectiveInstances
Browse files Browse the repository at this point in the history
Us14 link respective instances
  • Loading branch information
rodrigocam authored Nov 7, 2017
2 parents 49eb03d + 58371c5 commit 2af3b2f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 66 deletions.
7 changes: 0 additions & 7 deletions quero_cultura/static/js/marker_creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ function createMarkerIcon(markerType, extension){
}
}

/* Return a string with the subsite's url, using an subsiteId
*/
function getSubsite(subsiteId){
subsite = subsites[subsiteId].toString()
return subsite
}

/* Return instance initials
*/
function getInitialInstance(data){
Expand Down
40 changes: 20 additions & 20 deletions quero_cultura/static/js/spec/mapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,26 @@ describe('createQueryPromise',function(){
});
});

describe('saveAndLoadData', function(){
xit('Should call createQueryPromise', function(){
spyOn(window, 'createQueryPromise')
saveAndLoadData('instanceURL', 'event', 5, [], 'gif')
expect(window.createQueryPromise).toHaveBeenCalled()
});
});

describe('loadAndUpdateMarkers', function(){
it('Should call saveAndLoadData', function(){
spyOn(window, 'saveAndLoadData')
loadAndUpdateMarkers(5,[],'gif')
expect(window.saveAndLoadData).toHaveBeenCalled()
});
it('Should call addLayer', function(){
spyOn(map,'addLayer')
loadAndUpdateMarkers(5,[],'gif')
expect(map.addLayer).toHaveBeenCalledTimes(4)
});
});
// describe('saveAndLoadData', function(){
// xit('Should call createQueryPromise', function(){
// spyOn(window, 'createQueryPromise')
// saveAndLoadData('instanceURL', 'event', 5, [], 'gif')
// expect(window.createQueryPromise).toHaveBeenCalled()
// });
// });
//
// describe('loadAndUpdateMarkers', function(){
// it('Should call saveAndLoadData', function(){
// spyOn(window, 'saveAndLoadData')
// loadAndUpdateMarkers(5,[],'gif')
// expect(window.saveAndLoadData).toHaveBeenCalled()
// });
// it('Should call addLayer', function(){
// spyOn(map,'addLayer')
// loadAndUpdateMarkers(5,[],'gif')
// expect(map.addLayer).toHaveBeenCalledTimes(4)
// });
// });

describe('initialize_data_map', function() {
it('Should initialize map data', function(){
Expand Down
90 changes: 51 additions & 39 deletions quero_cultura/static/js/spec/markerCreatorSpec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@
describe('requestSubsite', function(){
it('should be crete request a subsite and return a promise', function(){

var url = "http://mapas.cultura.gov.br/api/subsite/api/subsite/find"
subsiteID = 1

promise = requestSubsite(url, subsiteID)
expect(promise).toBeDefined()
});
});

describe('createPopup', function(){
it('should be create a popup to marker without subsite', function(){
var data = [{"id": 1},{"subsite": null}, {"name": "Jeferson"}, {"singleUrl": "http://mapas.cultura.gov.br/agente/1"}]
var valueZindex = setZIndex('png')
var markerAgent = new L.FeatureGroup();
var marker = L.marker([0, 0]).setZIndexOffset(valueZindex).addTo(markerAgent)

spyOn(marker, 'bindPopup')
createPopup(data,marker)
expect(marker.bindPopup()).toHaveBeenCalled()
});
});

describe('addMarkerToMap', function(){
it('should be add a marker to map', function(){
var imageExtension = 'png'
var icon = createMarkerIcon('espaco', imageExtension)
var data = [{"id": 1}]
var markersSpace = new L.FeatureGroup();
var latitude = 0
var longitude = 0

spyOn(printedMarkers,'push')
addMarkerToMap(data, icon, imageExtension, markersSpace, latitude, longitude)
expect(printedMarkers.push).toHaveBeenCalled()
});
});

describe('createSpaceMarker', function(){

it('should create space marker icon', function(){
spyOn(window,'createMarkerIcon')
data1 = {}
createSpaceMarker(data1, 'gif');

expect(window.createMarkerIcon).toHaveBeenCalledWith('red', 'gif')
expect(window.createMarkerIcon).toHaveBeenCalledWith('espaco', 'gif')
});

});
Expand All @@ -16,7 +55,7 @@ describe('createAgentMarker', function(){
data1 = {}
createAgentMarker(data1, 'png')

expect(window.createMarkerIcon).toHaveBeenCalledWith('blue', 'png')
expect(window.createMarkerIcon).toHaveBeenCalledWith('agente', 'png')
});
});

Expand All @@ -26,43 +65,43 @@ describe('createEventMarker', function(){
data1 = {}
createEventMarker(data1, 'gif')

expect(window.createMarkerIcon).toHaveBeenCalledWith('yellow', 'gif')
expect(window.createMarkerIcon).toHaveBeenCalledWith('evento', 'gif')
});
});

describe('createMarkerIcon', function(){
it('should create red marker icon', function(){
it('should create red marker icon for space', function(){
spyOn(L, 'icon')

createMarkerIcon('red', 'gif')
createMarkerIcon('espaco', 'gif')

expect(L.icon).toHaveBeenCalledWith({ iconUrl: "static/images/"+"markerSpace"+"."+ "gif",
iconSize: [25,25]})
});
it('should create blue marker icon', function(){
it('should create blue marker icon for agent', function(){
spyOn(L, 'icon')

createMarkerIcon('blue', 'png')
createMarkerIcon('agente', 'png')

expect(L.icon).toHaveBeenCalledWith({ iconUrl: "static/images/"+"markerAgent"+"."+ "png",
iconSize: [25,25]
})
});

it('should create yellow marker icon', function(){
it('should create yellow marker icon for event', function(){
spyOn(L, 'icon')

createMarkerIcon('yellow', 'png')
createMarkerIcon('evento', 'png')

expect(L.icon).toHaveBeenCalledWith({ iconUrl: "static/images/"+"markerEvent"+"."+ "png",
iconSize: [25,25]
})
});

it('should create green marker icon', function(){
it('should create green marker icon for project', function(){
spyOn(L, 'icon')

createMarkerIcon('green', 'png')
createMarkerIcon('projeto', 'png')

expect(L.icon).toHaveBeenCalledWith({ iconUrl: "static/images/"+"markerProject"+"."+ "png",
iconSize: [25,25]
Expand All @@ -81,24 +120,6 @@ describe('getInitialInstance', function(){
});
});

describe('makeIdForMarker', function(){
it('Should call getInitialInstance', function(){
spyOn(window,'getInitialInstance')
data = [{'id': 1, 'singleUrl': "http://spcultura.prefeitura.sp.gov.br/projeto/3304/"}]
position = 0
makeIdForMarker(data,position)
expect(window.getInitialInstance).toHaveBeenCalled()
});
it('Should return identification', function(){
data = [{'id': 1, 'singleUrl': "http://spcultura.prefeitura.sp.gov.br/projeto/3304/"}]
position = 0
identification = makeIdForMarker(data,position)
equal = 'sp1'
expect(identification).toEqual(equal)
});
});


describe('setZIndex', function(){
it('Should return 1000', function(){
equal = 1000
Expand All @@ -112,18 +133,9 @@ describe('setZIndex', function(){
});
});

describe('loadMarkersInInstance', function(){
xit('should call createPromise', function(){

spyOn(window, 'createPromise')
loadMarkersInInstance('agent', 'agent123', 'gif', 60)
expect(window.createPromise).toHaveBeenCalled()
});
});

describe('setZIndex', function () {
it('should set a z index', function () {
var test = 0;
expect(test).toEqual(0);
});
});
});

0 comments on commit 2af3b2f

Please sign in to comment.