geospatialdraw
Version:
Geospatial Map Drawing Library
88 lines • 3.23 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
require("../../internal/tests");
var React = require("react");
var chai_1 = require("chai");
var enzyme_1 = require("enzyme");
var geometry_1 = require("../../geometry");
var units_1 = require("../units");
var bbox_editor_dialog_1 = require("./bbox-editor-dialog");
describe('bboxEditorDialog', function () {
var startGeo;
beforeEach(function () {
startGeo = (0, geometry_1.makeEmptyGeometry)('', 'Polygon');
startGeo.geometry.coordinates = [
[
[0, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 0],
],
];
startGeo.bbox = [0, 0, 0, 0];
});
describe('<BBoxEditorDialog />', function () {
it('render', function () {
var wrapper = (0, enzyme_1.shallow)(
// @ts-ignore
React.createElement(bbox_editor_dialog_1.BBoxEditorDialog
// @ts-ignore
, {
// @ts-ignore
geo: startGeo,
// @ts-ignore
coordinateUnit: units_1.LAT_LON, onUpdateGeo: function () { } }));
(0, chai_1.expect)(wrapper.exists()).to.equal(true);
});
});
describe('updateGeoWithExtentBBox', function () {
it('default', function () {
// @ts-ignore
var updated = (0, bbox_editor_dialog_1.updateGeoWithExtentBBox)(startGeo, [-5, -10, 5, 10]);
(0, chai_1.expect)(updated.bbox).to.deep.equal([-5, -10, 5, 10]);
(0, chai_1.expect)(updated.geometry.coordinates).to.deep.equal([
[
[-5, -10],
[-5, 10],
[5, 10],
[5, -10],
[-5, -10],
],
]);
});
});
describe('finalizeGeo', function () {
it('reversed coordinates', function () {
// @ts-ignore
var geo = (0, bbox_editor_dialog_1.updateGeoWithExtentBBox)(startGeo, [5, 10, -5, -10]);
var updated = (0, bbox_editor_dialog_1.finalizeGeo)(geo);
(0, chai_1.expect)(updated.bbox).to.deep.equal([-5, -10, 5, 10]);
(0, chai_1.expect)(updated.geometry.coordinates).to.deep.equal([
[
[-5, -10],
[-5, 10],
[5, 10],
[5, -10],
[-5, -10],
],
]);
});
it('half reversed coordinates', function () {
// @ts-ignore
var geo = (0, bbox_editor_dialog_1.updateGeoWithExtentBBox)(startGeo, [-5, 10, 5, -10]);
var updated = (0, bbox_editor_dialog_1.finalizeGeo)(geo);
(0, chai_1.expect)(updated.bbox).to.deep.equal([-5, -10, 5, 10]);
(0, chai_1.expect)(updated.geometry.coordinates).to.deep.equal([
[
[-5, -10],
[-5, 10],
[5, 10],
[5, -10],
[-5, -10],
],
]);
});
});
});
//# sourceMappingURL=bbox-editor-dialog.spec.js.map
;