@bluedot-innovation/models 5.1.23-alpha.2 → 5.1.24

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.1.24
2
+ - Using Double type for floating-point numbers instead of the type Number
3
+
1
4
  ## 5.1.23
2
5
  - Validate Geofeatures for missing type property
3
6
 
@@ -40,6 +40,14 @@ describe('BoundingBox', () => {
40
40
  done()
41
41
  })
42
42
  })
43
+
44
+ it('should return Double type for longitude and latitude', (done) => {
45
+ boundingBox.northEast = {"latitude": -37, "longitude": 144}
46
+ let BoundingBox = new BoundingBoxModel(boundingBox)
47
+ assert.isTrue(BoundingBox.northEast.latitude instanceof mongoose.Types.Double)
48
+ assert.isTrue(BoundingBox.northEast.longitude instanceof mongoose.Types.Double)
49
+ done()
50
+ })
43
51
  })
44
52
 
45
53
  describe('Invalid BoundingBox', () => {
@@ -39,6 +39,14 @@ testCase('Circle', () => {
39
39
  done()
40
40
  })
41
41
  })
42
+
43
+ assertions('should return Double type for longitude and latitude', (done) => {
44
+ circle.center = {"latitude": -37, "longitude": 144}
45
+ let Circle = new CircleModel(circle)
46
+ assert.isTrue(Circle.center.latitude instanceof mongoose.Types.Double)
47
+ assert.isTrue(Circle.center.longitude instanceof mongoose.Types.Double)
48
+ done()
49
+ })
42
50
  })
43
51
 
44
52
  testCase('Invalid Circle', () => {
@@ -39,6 +39,14 @@ testCase('Geoline', () => {
39
39
  done()
40
40
  })
41
41
  })
42
+
43
+ assertions('should return Double type for longitude and latitude', (done) => {
44
+ geoline.vertices[0] = {"latitude": -37, "longitude": 144}
45
+ let Geoline = new GeolineModel(geoline)
46
+ assert.isTrue(Geoline.vertices[0].latitude instanceof mongoose.Types.Double)
47
+ assert.isTrue(Geoline.vertices[0].longitude instanceof mongoose.Types.Double)
48
+ done()
49
+ })
42
50
  })
43
51
 
44
52
  testCase('Invalid Geoline', () => {
@@ -34,6 +34,14 @@ describe('Polygon', () => {
34
34
  done()
35
35
  })
36
36
  })
37
+
38
+ it('should return Double type for longitude and latitude', (done) => {
39
+ polygon.vertices[0] = {"latitude": -37, "longitude": 144}
40
+ let Polygon = new PolygonModel(polygon)
41
+ assert.isTrue(Polygon.vertices[0].latitude instanceof mongoose.Types.Double)
42
+ assert.isTrue(Polygon.vertices[0].longitude instanceof mongoose.Types.Double)
43
+ done()
44
+ })
37
45
  })
38
46
 
39
47
  describe('Invalid Polygon', () => {
@@ -38,6 +38,14 @@ describe('ZoneBeacon', () => {
38
38
  done()
39
39
  })
40
40
  })
41
+
42
+ it('should return Double type for longitude and latitude', (done) => {
43
+ zoneBeacon.location = {"latitude": -37, "longitude": 144}
44
+ const ZoneBeacon = new ZoneBeaconModel(zoneBeacon)
45
+ assert.isTrue(ZoneBeacon.location.latitude instanceof mongoose.Types.Double)
46
+ assert.isTrue(ZoneBeacon.location.longitude instanceof mongoose.Types.Double)
47
+ done()
48
+ })
41
49
  })
42
50
 
43
51
  describe('Invalid ZoneBeacon', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.23-alpha.2",
3
+ "version": "5.1.24",
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",
@@ -1,10 +1,11 @@
1
1
  let mongoose = require('mongoose')
2
+ const Double = require('@mongoosejs/double')
2
3
 
3
4
  let PointGeometrySchema = new mongoose.Schema(
4
5
  {
5
6
  type: {type: String, match: /Point/},
6
- coordinates: [{type: Number, required: [true, 'longitude is required. '], min: -180, max: 180},
7
- {type: Number, required: [true, 'latitude is required. '], min: -90, max: 90}]
7
+ coordinates: [{type: Double, required: [true, 'longitude is required. '], min: -180, max: 180},
8
+ {type: Double, required: [true, 'latitude is required. '], min: -90, max: 90}]
8
9
  },
9
10
  {
10
11
  _id: false,