forked from publiclab/leaflet-environmental-layers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Eonet Fires Layer (publiclab#407)
- Loading branch information
Showing
2 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"title": "EONET Events: Wildfires", | ||
"description": "Wildfires includes all nature of fire, including forest and plains fires, as well as urban and industrial fire events. Fires may be naturally caused or manmade.", | ||
"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/categories/8", | ||
"events": [ | ||
{ | ||
"id": "EONET_4583", | ||
"title": "Wildfire - Hualqui, Chile", | ||
"description": "", | ||
"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_4583", | ||
"categories": [ | ||
{ | ||
"id": 8, | ||
"title": "Wildfires" | ||
} | ||
], | ||
"sources": [ | ||
{ | ||
"id": "PDC", | ||
"url": "http://emops.pdc.org/emops/?hazard_id=103237" | ||
} | ||
], | ||
"geometries": [ | ||
{ | ||
"date": "2020-02-12T18:19:00Z", | ||
"type": "Point", | ||
"coordinates": [ | ||
-72.93736, | ||
-36.97488 | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "EONET_4581", | ||
"title": "Wildfire - Molina, Chile", | ||
"description": "", | ||
"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_4581", | ||
"categories": [ | ||
{ | ||
"id": 8, | ||
"title": "Wildfires" | ||
} | ||
], | ||
"sources": [ | ||
{ | ||
"id": "PDC", | ||
"url": "http://emops.pdc.org/emops/?hazard_id=103236" | ||
} | ||
], | ||
"geometries": [ | ||
{ | ||
"date": "2020-02-12T18:18:00Z", | ||
"type": "Point", | ||
"coordinates": [ | ||
-70.989940082, | ||
-35.078969559 | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "EONET_4582", | ||
"title": "Wildfire - Renaico, Chile", | ||
"description": "", | ||
"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_4582", | ||
"categories": [ | ||
{ | ||
"id": 8, | ||
"title": "Wildfires" | ||
} | ||
], | ||
"sources": [ | ||
{ | ||
"id": "PDC", | ||
"url": "http://emops.pdc.org/emops/?hazard_id=103235" | ||
} | ||
], | ||
"geometries": [ | ||
{ | ||
"date": "2020-02-12T18:17:00Z", | ||
"type": "Point", | ||
"coordinates": [ | ||
-72.663116693, | ||
-37.690599087 | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "EONET_4584", | ||
"title": "Wildfire - Penco, Chile", | ||
"description": "", | ||
"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_4584", | ||
"categories": [ | ||
{ | ||
"id": 8, | ||
"title": "Wildfires" | ||
} | ||
], | ||
"sources": [ | ||
{ | ||
"id": "PDC", | ||
"url": "http://emops.pdc.org/emops/?hazard_id=103234" | ||
} | ||
], | ||
"geometries": [ | ||
{ | ||
"date": "2020-02-12T18:15:00Z", | ||
"type": "Point", | ||
"coordinates": [ | ||
-72.98808, | ||
-36.73282 | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
describe('Eonet fires layer', function() { | ||
it('adds markers on click', function() { | ||
cy.openWindow('/example/index.html#lat=43.00&lon=-83.00&zoom=3&layers=Standard') | ||
cy.wait(5000) | ||
cy.window().then((win) => { | ||
cy.fixture('eonetFiresLayer').then((data) => { | ||
cy.stub(win.EonetFiresLayer, 'requestData', function() { | ||
win.EonetFiresLayer.parseData(data); | ||
}) | ||
}) | ||
|
||
cy.get('#menu-EONET_Fires label').click({ force: true }) | ||
cy.get('.leaflet-marker-pane').children().should('have.length', 4) | ||
}) | ||
}) | ||
|
||
it('should have the layer name added to the hash', function() { | ||
cy.hash().should('eq', '#lat=43.00&lon=-82.97&zoom=3&layers=Standard,eonetFiresLayer') | ||
}) | ||
|
||
it('has default markers in default mode', function() { | ||
cy.get('.leaflet-marker-pane img').invoke('attr', 'src').should('eq', 'https://image.flaticon.com/icons/svg/785/785116.svg') | ||
cy.get('.leaflet-marker-pane img[src="https://image.flaticon.com/icons/svg/785/785116.svg"]').should('have.length', 4) | ||
}) | ||
|
||
it('has circle markers in minimal mode', function() { | ||
cy.server() | ||
cy.route('GET', 'https://eonet.sci.gsfc.nasa.gov/api/v2.1/categories/8', 'fixture:eonetFiresLayer.json') | ||
const spy = cy.spy(window.top.aut.EonetFiresLayer, 'requestData') | ||
cy.get('[title="Show minimal markers"]').click().then(() => { | ||
expect(spy).to.be.called | ||
cy.get('.leaflet-overlay-pane svg g').children().should('have.length', 4) | ||
cy.get('.leaflet-overlay-pane svg g path').invoke('attr', 'stroke').should('eq', '#7c7c7c') | ||
cy.get('.leaflet-overlay-pane svg g path').invoke('attr', 'fill').should('eq', '#ff421d') | ||
cy.get('.leaflet-overlay-pane svg g path').invoke('attr', 'stroke-linecap').should('eq', 'round') | ||
cy.get('.leaflet-overlay-pane svg g path').invoke('attr', 'stroke-linecap').should('eq', 'round') | ||
}) | ||
}) | ||
|
||
it('removes markers from the map and the layer name from the hash when clicked again', function() { | ||
cy.get('#menu-EONET_Fires label').click({ force: true }) | ||
cy.hash().should('eq', '#lat=43.00&lon=-82.97&zoom=3&layers=Standard') | ||
cy.get('.leaflet-marker-pane').children().should('have.length', 0) | ||
cy.get('.leaflet-overlay-pane svg g').children().should('have.length', 0) | ||
}) | ||
|
||
}) |