diff --git a/quero_cultura/static/js/marker_creators.js b/quero_cultura/static/js/marker_creators.js index 28bca2d..a67617a 100644 --- a/quero_cultura/static/js/marker_creators.js +++ b/quero_cultura/static/js/marker_creators.js @@ -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){ diff --git a/quero_cultura/static/js/spec/mapSpec.js b/quero_cultura/static/js/spec/mapSpec.js index 9ec8666..9ff3143 100644 --- a/quero_cultura/static/js/spec/mapSpec.js +++ b/quero_cultura/static/js/spec/mapSpec.js @@ -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(){ diff --git a/quero_cultura/static/js/spec/markerCreatorSpec.js b/quero_cultura/static/js/spec/markerCreatorSpec.js index 1eee0cc..6473cc5 100644 --- a/quero_cultura/static/js/spec/markerCreatorSpec.js +++ b/quero_cultura/static/js/spec/markerCreatorSpec.js @@ -1,3 +1,42 @@ +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(){ @@ -5,7 +44,7 @@ describe('createSpaceMarker', function(){ data1 = {} createSpaceMarker(data1, 'gif'); - expect(window.createMarkerIcon).toHaveBeenCalledWith('red', 'gif') + expect(window.createMarkerIcon).toHaveBeenCalledWith('espaco', 'gif') }); }); @@ -16,7 +55,7 @@ describe('createAgentMarker', function(){ data1 = {} createAgentMarker(data1, 'png') - expect(window.createMarkerIcon).toHaveBeenCalledWith('blue', 'png') + expect(window.createMarkerIcon).toHaveBeenCalledWith('agente', 'png') }); }); @@ -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] @@ -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 @@ -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); }); -}); \ No newline at end of file +});