Skip to content

Commit

Permalink
added test for leaflet drawsupport
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored and offtherailz committed Jul 27, 2017
1 parent 8777146 commit 9372135
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 2 deletions.
71 changes: 69 additions & 2 deletions web/client/components/map/leaflet/__tests__/DrawSupport-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var React = require('react');
var ReactDOM = require('react-dom');
var L = require('leaflet');
var DrawSupport = require('../DrawSupport');

const {} = require('../../../../test-resources/drawsupport/features');
describe('Leaflet DrawSupport', () => {
var msNode;

Expand Down Expand Up @@ -75,6 +75,14 @@ describe('Leaflet DrawSupport', () => {
zoom: 13
});
let cmp = ReactDOM.render(
<DrawSupport
map={map}
drawOwner="me"
drawStatus="create"
drawMethod="Point"
/>
, msNode);
cmp = ReactDOM.render(
<DrawSupport
map={map}
drawOwner="me"
Expand Down Expand Up @@ -105,7 +113,15 @@ describe('Leaflet DrawSupport', () => {
center: [51.505, -0.09],
zoom: 13
});
const cmp = ReactDOM.render(
let cmp = ReactDOM.render(
<DrawSupport
map={map}
drawOwner="me"
drawStatus="start"
drawMethod="Point"
/>
, msNode);
cmp = ReactDOM.render(
<DrawSupport
map={map}
drawOwner="me"
Expand All @@ -128,6 +144,16 @@ describe('Leaflet DrawSupport', () => {
drawOwner="me"
drawStatus="create"
drawMethod="LineString"
options={{editEnabled: true}}
/>
, msNode);
cmp = ReactDOM.render(
<DrawSupport
map={map}
drawOwner="me"
drawStatus="create"
drawMethod="LineString"
options={{editEnabled: false}}
/>
, msNode);
expect(cmp).toExist();
Expand All @@ -146,5 +172,46 @@ describe('Leaflet DrawSupport', () => {
/>
, msNode);
});
it('test editEnabled=true', () => {
let map = L.map("map", {
center: [51.505, -0.09],
zoom: 13
});
let cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Point" features={[]} options={{editEnabled: false}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Point" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="LineString" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Polygon" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiPoint" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiLineString" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiPolygon" features={[]} options={{editEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiPolygon" features={[]} options={{editEnabled: true}} />, msNode);
expect(cmp).toExist();

});
it('test drawEnabled=true', () => {
let map = L.map("map", {
center: [51.505, -0.09],
zoom: 13
});
let cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Point" features={[]} options={{drawEnabled: false}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Point" features={[]} options={{drawEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="LineString" features={[]} options={{drawEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="Polygon" features={[]} options={{drawEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiPoint" features={[]} options={{drawEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiLineString" features={[]} options={{drawEnabled: true}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="drawOrEdit" drawMethod="MultiPolygon" features={[]} options={{drawEnabled: true}} />, msNode);
expect(cmp).toExist();

});
it('test stop status', () => {
let map = L.map("map", {
center: [51.505, -0.09],
zoom: 13
});
let cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="start" drawMethod="LineString" options={{}} />, msNode);
cmp = ReactDOM.render( <DrawSupport map={map} drawOwner="me" drawStatus="stop" drawMethod="LineString" options={{}} />, msNode);
expect(cmp).toExist();

});

});
56 changes: 56 additions & 0 deletions web/client/test-resources/drawsupport/features.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
pointFt: {
type: "Feature",
geometry: {
type: "Point",
coordinates: [40, -30]
},
id: "point",
properties: {}
},
lineStringFt: {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[40, -30], [41, -30]]
},
id: "linestring",
properties: {}
},
polygonFt: {
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [[[40, -30], [41, -31], [43, -32], [40, -30]]]
},
id: "polygon",
properties: {}
},
multipointFt: {
type: "Feature",
geometry: {
type: "MultiPoint",
coordinates: [[40, -30]]
},
id: "multipoint",
properties: {}
},
multilineStringFt: {
type: "Feature",
geometry: {
type: "MultiLineString",
coordinates: [[[40, -30], [41, -30]]]
},
id: "multilinestring",
properties: {}
},
multipolygonFt: {
type: "Feature",
geometry: {
type: "MultiPolygon",
coordinates: [[[[40, -30], [41, -31], [43, -32], [40, -30]]]]
},
id: "multipolygon",
properties: {}
}
};

0 comments on commit 9372135

Please sign in to comment.