-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ce1543
commit 25c2e23
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { isPlainObject, isObject, omitBy } from 'lodash/fp' | ||
import { pickBy, isNumber, isString, isBoolean, isPlainObject } from 'lodash/fp' | ||
/** | ||
* @func | ||
* @param {Object} value | ||
* @param {Object} Returns object only with plain properties. | ||
*/ | ||
const plainProps = omitBy(x => isObject(x) && !isPlainObject(x)) | ||
const plainProps = pickBy(x => isNumber(x) || | ||
isString(x) || | ||
Array.isArray(x) || | ||
isBoolean(x) || | ||
isPlainObject(x)) | ||
export default plainProps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as coordinateHelper from 'vl-ol/coordinate' | ||
|
||
describe('ol coordinate helper', () => { | ||
const point3857 = [ 5565974.539663679, 7361866.113051185 ] | ||
const point4326 = [ 50, 55 ] | ||
const line3857 = [ [ 5565974.539663679, 7361866.113051185 ], [ -3896182.1777645755, -11068715.659379495 ] ] | ||
const line4326 = [ [ 50, 55 ], [ -35, -70 ] ] | ||
|
||
describe('pointToLonLat', () => { | ||
it('should transform point coordinate to EPSG:4326', () => { | ||
expect(coordinateHelper.pointToLonLat(point3857, 'EPSG:3857')).to.be.deep.equal(point4326) | ||
}) | ||
}) | ||
|
||
describe('pointFromLonLat', () => { | ||
it('should transform point coordinate from EPSG:4326', () => { | ||
expect(coordinateHelper.pointFromLonLat(point4326, 'EPSG:3857')).to.be.deep.equal(point3857) | ||
}) | ||
}) | ||
|
||
describe('lineToLonLat', () => { | ||
it('should transform line coordinate to EPSG:4326', () => { | ||
expect(coordinateHelper.lineToLonLat(line3857, 'EPSG:3857')).to.be.deep.equal(line4326) | ||
}) | ||
}) | ||
|
||
describe('lineFromLonLat', () => { | ||
it('should transform line coordinate from EPSG:4326', () => { | ||
expect(coordinateHelper.lineFromLonLat(line4326, 'EPSG:3857')).to.be.deep.equal(line3857) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import plainProps from 'vl-utils/plain-props' | ||
|
||
describe('plain-props', () => { | ||
it('should clean the object from non-plain values', () => { | ||
const obj = { | ||
num: 123, | ||
str: 'qwe', | ||
arr: [ 1, 2, 3 ], | ||
func () {}, | ||
inst: new Ctor() | ||
} | ||
const expected = { | ||
num: 123, | ||
str: 'qwe', | ||
arr: [ 1, 2, 3 ] | ||
} | ||
|
||
expect(plainProps(obj)).to.be.deep.equal(expected) | ||
}) | ||
}) | ||
|
||
function Ctor () {} |