@bluedot-innovation/models 10.0.0-beta-6 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,17 @@ describe('BoundingBox', () => {
34
34
  const res = await BoundingBox.validate()
35
35
  assert.notExists(res)
36
36
  })
37
+
38
+ it('should return double for longitude and latitude', () => {
39
+ boundingBox.northEast = {"latitude": -37, "longitude": 144}
40
+ let BoundingBox = new BoundingBoxModel(boundingBox)
41
+ assert.equal(BoundingBox.northEast.longitude, 144.0000001)
42
+ assert.isBelow(Math.abs(BoundingBox.northEast.longitude - 144), 0.000001)
43
+ assert.equal(BoundingBox.northEast.latitude, -36.9999999)
44
+ assert.isBelow(Math.abs(BoundingBox.northEast.latitude + 37), 0.000001)
45
+ assert.isFalse(Number.isInteger(BoundingBox.northEast.latitude))
46
+ assert.isFalse(Number.isInteger(BoundingBox.northEast.longitude))
47
+ })
37
48
  })
38
49
 
39
50
  describe('Invalid BoundingBox', () => {
@@ -33,6 +33,18 @@ testCase('Circle', () => {
33
33
  const res = await Circle.validate()
34
34
  assert.notExists(res)
35
35
  })
36
+
37
+ assertions('should transfer integer coordinate to double', async () => {
38
+ circle.center.longitude = 144
39
+ circle.center.latitude = -37
40
+ let Circle = new CircleModelBuiltInMongoose(circle)
41
+ assert.equal(Circle.center.longitude, 144.0000001)
42
+ assert.isBelow(Math.abs(Circle.center.longitude - 144), 0.000001)
43
+ assert.equal(Circle.center.latitude, -36.9999999)
44
+ assert.isBelow(Math.abs(Circle.center.latitude + 37), 0.000001)
45
+ assert.isFalse(Number.isInteger(Circle.center.longitude))
46
+ assert.isFalse(Number.isInteger(Circle.center.latitude))
47
+ })
36
48
  })
37
49
 
38
50
  testCase('Invalid Circle', () => {
@@ -45,7 +57,7 @@ testCase('Circle', () => {
45
57
  } catch (err) {
46
58
  assert.exists(err, 'err object should exist')
47
59
  assert.isObject(err.errors)
48
- assert.strictEqual(err.errors.radius.message, `radius [3m] must be greater than 5m`)
60
+ assert.strictEqual(err.errors.radius.message, `radius [3.0000001m] must be greater than 5m`)
49
61
  }
50
62
  })
51
63
 
@@ -33,6 +33,17 @@ testCase('Geoline', () => {
33
33
  const res = await Geoline.validate()
34
34
  assert.notExists(res)
35
35
  })
36
+
37
+ assertions('should return Double for longitude and latitude', () => {
38
+ geoline.vertices[0] = {"latitude": -37, "longitude": 144}
39
+ let Geoline = new GeolineModel(geoline)
40
+ assert.equal(Geoline.vertices[0].longitude, 144.0000001)
41
+ assert.isBelow(Math.abs(Geoline.vertices[0].longitude - 144), 0.000001)
42
+ assert.equal(Geoline.vertices[0].latitude, -36.9999999)
43
+ assert.isBelow(Math.abs(Geoline.vertices[0].latitude + 37), 0.000001)
44
+ assert.isFalse(Number.isInteger(Geoline.vertices[0].longitude))
45
+ assert.isFalse(Number.isInteger(Geoline.vertices[0].latitude))
46
+ })
36
47
  })
37
48
 
38
49
  testCase('Invalid Geoline', () => {
@@ -28,6 +28,17 @@ describe('Polygon', () => {
28
28
  const res = await Polygon.validate()
29
29
  assert.notExists(res)
30
30
  })
31
+
32
+ it('should return Double for longitude and latitude', () => {
33
+ polygon.vertices[0] = {"latitude": -37, "longitude": 144}
34
+ let Polygon = new PolygonModel(polygon)
35
+ assert.equal(Polygon.vertices[0].longitude, 144.0000001)
36
+ assert.isBelow(Math.abs(Polygon.vertices[0].longitude - 144), 0.000001)
37
+ assert.equal(Polygon.vertices[0].latitude, -36.9999999)
38
+ assert.isBelow(Math.abs(Polygon.vertices[0].latitude + 37), 0.000001)
39
+ assert.isFalse(Number.isInteger(Polygon.vertices[0].longitude))
40
+ assert.isFalse(Number.isInteger(Polygon.vertices[0].latitude))
41
+ })
31
42
  })
32
43
 
33
44
  describe('Invalid Polygon', () => {
package/helpers.js CHANGED
@@ -268,12 +268,7 @@ helpers.validateNoDuplicateReportConfigurations = function(reportConfigArray) {
268
268
  }
269
269
 
270
270
  helpers.transformNumbertoDouble = (value) => {
271
- try {
272
- return value === null ? null : parseFloat(value).toFixed(6)
273
- } catch(err) {
274
- return value
275
- }
276
-
271
+ return Number.isInteger(value) ? value + 0.0000001 : value
277
272
  }
278
273
 
279
274
  module.exports = helpers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "10.0.0-beta-6",
3
+ "version": "10.0.0",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",