Fix Choropleth JS tests
This commit is contained in:
parent
7be238a4ab
commit
84a5b3c6f5
2 changed files with 7 additions and 14 deletions
|
@ -178,12 +178,6 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
removeLayer: function (layer) {
|
|
||||||
var id = layer in this._layers ? layer : this.getLayerId(layer);
|
|
||||||
delete this._layers[id];
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
this.computeLimits()
|
this.computeLimits()
|
||||||
L.FeatureGroup.prototype.onAdd.call(this, map)
|
L.FeatureGroup.prototype.onAdd.call(this, map)
|
||||||
|
@ -478,7 +472,7 @@ L.U.DataLayer = L.Evented.extend({
|
||||||
if (visible) this.map.removeLayer(this.layer)
|
if (visible) this.map.removeLayer(this.layer)
|
||||||
const Class = L.U.Layer[this.options.type] || L.U.Layer.Default
|
const Class = L.U.Layer[this.options.type] || L.U.Layer.Default
|
||||||
this.layer = new Class(this)
|
this.layer = new Class(this)
|
||||||
this.eachLayer((feature) => this.showFeature(feature))
|
this.eachLayer(this.showFeature)
|
||||||
if (visible) this.show()
|
if (visible) this.show()
|
||||||
this.propagateRemote()
|
this.propagateRemote()
|
||||||
},
|
},
|
||||||
|
|
|
@ -188,6 +188,10 @@ describe('L.U.Choropleth', function () {
|
||||||
this.map = initMap({ umap_id: 99 })
|
this.map = initMap({ umap_id: 99 })
|
||||||
this.datalayer = this.map.getDataLayerByUmapId(62)
|
this.datalayer = this.map.getDataLayerByUmapId(62)
|
||||||
this.server.respond()
|
this.server.respond()
|
||||||
|
this.datalayer.options.type = 'Choropleth'
|
||||||
|
this.datalayer.options.choropleth = {
|
||||||
|
property: 'value',
|
||||||
|
}
|
||||||
enableEdit()
|
enableEdit()
|
||||||
this.datalayer.eachLayer(function (layer) {
|
this.datalayer.eachLayer(function (layer) {
|
||||||
if (layer.properties.name === 'number 1') {
|
if (layer.properties.name === 'number 1') {
|
||||||
|
@ -211,12 +215,7 @@ describe('L.U.Choropleth', function () {
|
||||||
})
|
})
|
||||||
describe('#compute()', function () {
|
describe('#compute()', function () {
|
||||||
it('choropleth should compute default colors', function () {
|
it('choropleth should compute default colors', function () {
|
||||||
this.datalayer.options.type = 'Choropleth'
|
this.datalayer.resetLayer(true)
|
||||||
this.datalayer.options.choropleth = {
|
|
||||||
property: 'value',
|
|
||||||
}
|
|
||||||
this.datalayer.resetLayer()
|
|
||||||
DATALAYER = this.datalayer
|
|
||||||
// Does not pass because chroma-js seems to have rounding issues
|
// Does not pass because chroma-js seems to have rounding issues
|
||||||
//assert.deepEqual(this.datalayer.layer.options.limits, [45, 438.6, 707.0, 3231.0, 4935.2, 9898])
|
//assert.deepEqual(this.datalayer.layer.options.limits, [45, 438.6, 707.0, 3231.0, 4935.2, 9898])
|
||||||
assert.equal(poly1._path.attributes.fill.value, '#ffffff')
|
assert.equal(poly1._path.attributes.fill.value, '#ffffff')
|
||||||
|
@ -226,12 +225,12 @@ describe('L.U.Choropleth', function () {
|
||||||
it('choropleth should compute brewer colors', function () {
|
it('choropleth should compute brewer colors', function () {
|
||||||
this.datalayer.options.choropleth.brewer = 'Blues'
|
this.datalayer.options.choropleth.brewer = 'Blues'
|
||||||
this.datalayer.resetLayer(true)
|
this.datalayer.resetLayer(true)
|
||||||
DATALAYER = this.datalayer
|
|
||||||
assert.equal(poly1._path.attributes.fill.value, '#f7fbff')
|
assert.equal(poly1._path.attributes.fill.value, '#f7fbff')
|
||||||
assert.equal(poly4._path.attributes.fill.value, '#c6dbef')
|
assert.equal(poly4._path.attributes.fill.value, '#c6dbef')
|
||||||
assert.equal(poly9._path.attributes.fill.value, '#08306b')
|
assert.equal(poly9._path.attributes.fill.value, '#08306b')
|
||||||
})
|
})
|
||||||
it('choropleth should allow to change steps', function () {
|
it('choropleth should allow to change steps', function () {
|
||||||
|
this.datalayer.options.choropleth.brewer = 'Blues'
|
||||||
this.datalayer.options.choropleth.steps = 6
|
this.datalayer.options.choropleth.steps = 6
|
||||||
this.datalayer.resetLayer(true)
|
this.datalayer.resetLayer(true)
|
||||||
assert.equal(poly1._path.attributes.fill.value, '#f7fbff')
|
assert.equal(poly1._path.attributes.fill.value, '#f7fbff')
|
||||||
|
|
Loading…
Reference in a new issue