From 45d90cde72543b94d2de090f05711883c0938092 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 24 Jun 2020 10:43:15 -0600 Subject: [PATCH] Additional test coverage for serializing GeoJSON --- test/spec/ol/format/geojson.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/spec/ol/format/geojson.test.js b/test/spec/ol/format/geojson.test.js index 71893417de..9efcc8d6b6 100644 --- a/test/spec/ol/format/geojson.test.js +++ b/test/spec/ol/format/geojson.test.js @@ -673,6 +673,22 @@ describe('ol.format.GeoJSON', function () { const feature = new Feature(new Point([5, 10])); const geojson = format.writeFeatureObject(feature); expect(geojson.properties).to.eql(null); + expect(geojson.geometry).to.eql({type: 'Point', coordinates: [5, 10]}); + }); + + it('writes out a feature with only non-geometry properties correctly', function () { + const feature = new Feature({foo: 'bar'}); + const geojson = format.writeFeatureObject(feature); + expect(geojson.geometry).to.eql(null); + expect(geojson.properties).to.eql({foo: 'bar'}); + }); + + it('writes out a feature with deleted properties correctly', function () { + const feature = new Feature({foo: 'bar'}); + feature.unset('foo'); + const geojson = format.writeFeatureObject(feature); + expect(geojson.geometry).to.eql(null); + expect(geojson.properties).to.eql(null); }); it('writes out a feature without geometry correctly', function () {