Fix zoomEnd tests

By moving the tests that delete the datalayer at the end.
This commit is contained in:
Yohan Boniface 2023-12-23 09:12:34 +01:00
parent acfcc2e2a6
commit 01d89dbd93

View file

@ -332,47 +332,6 @@ describe('L.U.DataLayer', function () {
}) })
}) })
describe('#delete()', function () {
var deleteLink,
deletePath = '/map/99/datalayer/delete/62/'
it('should have a delete link in update form', function () {
enableEdit()
happen.click(
qs('#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-edit')
)
deleteLink = qs('button.delete_datalayer_button')
assert.ok(deleteLink)
})
it('should delete features on datalayer delete', function () {
happen.click(deleteLink)
assert.notOk(qs('div.icon_container'))
})
it('should have set map dirty', function () {
assert.ok(this.map.isDirty)
})
it('should delete layer control row on delete', function () {
assert.notOk(
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(this.datalayer))
)
})
it('should be removed from map.datalayers_index', function () {
assert.equal(this.map.datalayers_index.indexOf(this.datalayer), -1)
})
it('should be removed from map.datalayers', function () {
assert.notOk(this.map.datalayers[L.stamp(this.datalayer)])
})
it('should be visible again on edit cancel', function () {
clickCancel()
assert.ok(qs('div.icon_container'))
})
})
describe('#smart-options()', function () { describe('#smart-options()', function () {
let poly, marker let poly, marker
before(function () { before(function () {
@ -404,40 +363,6 @@ describe('L.U.DataLayer', function () {
}) })
}) })
describe("#displayOnLoad", function () {
beforeEach(function () {
this.server.respondWith(
/\/datalayer\/64\/\?.*/,
JSON.stringify(RESPONSES.datalayer64_GET)
)
this.datalayer = this.map.createDataLayer(RESPONSES.datalayer64_GET._umap_options)
// Force fetching the data, so to deal here with fake server
this.datalayer.fetchData()
this.server.respond()
this.map.setZoom(10, {animate: false})
});
afterEach(function () {
this.datalayer._delete()
})
it("should not display layer at load", function () {
assert.notOk(qs('path[fill="AliceBlue"]'))
})
it("should display on click", function () {
happen.click(qs(`[data-id='${L.stamp(this.datalayer)}'] .layer-toggle`))
assert.ok(qs('path[fill="AliceBlue"]'))
})
it("should not display on zoom", function () {
this.map.setZoom(9, {animate: false})
assert.notOk(qs('path[fill="AliceBlue"]'))
})
})
describe('#facet-search()', function () { describe('#facet-search()', function () {
before(function () { before(function () {
this.server.respondWith( this.server.respondWith(
@ -493,4 +418,78 @@ describe('L.U.DataLayer', function () {
assert.ok(qs('path[fill="none"]')) assert.ok(qs('path[fill="none"]'))
}) })
}) })
describe('#displayOnLoad', function () {
beforeEach(function () {
this.server.respondWith(
/\/datalayer\/64\/\?.*/,
JSON.stringify(RESPONSES.datalayer64_GET)
)
this.datalayer = this.map.createDataLayer(RESPONSES.datalayer64_GET._umap_options)
// Force fetching the data, so to deal here with fake server
this.datalayer.fetchData()
this.server.respond()
this.map.setZoom(10, { animate: false })
})
afterEach(function () {
this.datalayer._delete()
})
it('should not display layer at load', function () {
assert.notOk(qs('path[fill="AliceBlue"]'))
})
it('should display on click', function () {
happen.click(qs(`[data-id='${L.stamp(this.datalayer)}'] .layer-toggle`))
assert.ok(qs('path[fill="AliceBlue"]'))
})
it('should not display on zoom', function () {
this.map.setZoom(9, { animate: false })
assert.notOk(qs('path[fill="AliceBlue"]'))
})
})
describe('#delete()', function () {
var deleteLink,
deletePath = '/map/99/datalayer/delete/62/'
it('should have a delete link in update form', function () {
enableEdit()
happen.click(
qs('#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-edit')
)
deleteLink = qs('button.delete_datalayer_button')
assert.ok(deleteLink)
})
it('should delete features on datalayer delete', function () {
happen.click(deleteLink)
assert.notOk(qs('div.icon_container'))
})
it('should have set map dirty', function () {
assert.ok(this.map.isDirty)
})
it('should delete layer control row on delete', function () {
assert.notOk(
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(this.datalayer))
)
})
it('should be removed from map.datalayers_index', function () {
assert.equal(this.map.datalayers_index.indexOf(this.datalayer), -1)
})
it('should be removed from map.datalayers', function () {
assert.notOk(this.map.datalayers[L.stamp(this.datalayer)])
})
it('should be visible again on edit cancel', function () {
clickCancel()
assert.ok(qs('div.icon_container'))
})
})
}) })