@bluedot-innovation/models 10.0.0-beta-7 → 10.1.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.
- package/CHANGELOG.md +3 -0
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +11 -0
- package/__tests__/geofeature/circle/circle.spec.js +6 -2
- package/__tests__/geofeature/geoline/geoline.spec.js +11 -0
- package/__tests__/geofeature/polygon/polygon.spec.js +11 -0
- package/__tests__/project/project.data.json +4 -0
- package/__tests__/project/project.spec.js +13 -0
- package/helpers.js +1 -1
- package/models/geofeatures/Circle.js +2 -0
- package/package.json +1 -1
- package/schemas/Integration.js +3 -1
- package/schemas/UberEatsIntegration.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -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', () => {
|
|
@@ -39,7 +39,11 @@ testCase('Circle', () => {
|
|
|
39
39
|
circle.center.latitude = -37
|
|
40
40
|
let Circle = new CircleModelBuiltInMongoose(circle)
|
|
41
41
|
assert.equal(Circle.center.longitude, 144.0000001)
|
|
42
|
-
assert.
|
|
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))
|
|
43
47
|
})
|
|
44
48
|
})
|
|
45
49
|
|
|
@@ -53,7 +57,7 @@ testCase('Circle', () => {
|
|
|
53
57
|
} catch (err) {
|
|
54
58
|
assert.exists(err, 'err object should exist')
|
|
55
59
|
assert.isObject(err.errors)
|
|
56
|
-
assert.strictEqual(err.errors.radius.message, `radius [
|
|
60
|
+
assert.strictEqual(err.errors.radius.message, `radius [3.0000001m] must be greater than 5m`)
|
|
57
61
|
}
|
|
58
62
|
})
|
|
59
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', () => {
|
|
@@ -1034,6 +1034,19 @@ describe('Project', () => {
|
|
|
1034
1034
|
}
|
|
1035
1035
|
})
|
|
1036
1036
|
})
|
|
1037
|
+
|
|
1038
|
+
describe("Ubereats integration validation", () => {
|
|
1039
|
+
it('should throw an error when enabled is not boolean', async () => {
|
|
1040
|
+
project.integrations.uberEats.enabled = 'test'
|
|
1041
|
+
let Project = new ProjectModel(project)
|
|
1042
|
+
try {
|
|
1043
|
+
await Project.validate()
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
assert.exists(err, 'err object should exist')
|
|
1046
|
+
assert.match(err.message, /Cast to Boolean failed for value .*enabled/)
|
|
1047
|
+
}
|
|
1048
|
+
})
|
|
1049
|
+
})
|
|
1037
1050
|
})
|
|
1038
1051
|
|
|
1039
1052
|
describe('should throw an error when any of the values of the array contains a falsy value', () => {
|
package/helpers.js
CHANGED
|
@@ -268,7 +268,7 @@ helpers.validateNoDuplicateReportConfigurations = function(reportConfigArray) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
helpers.transformNumbertoDouble = (value) => {
|
|
271
|
-
return Number.isInteger(value) ?
|
|
271
|
+
return Number.isInteger(value) ? value + 0.0000001 : value
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
module.exports = helpers
|
|
@@ -2,6 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
let ZoneEnum = require('@bluedot-innovation/enums').ZoneEnum
|
|
3
3
|
let Point = require('../../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
|
+
const { transformNumbertoDouble } = require('../../helpers')
|
|
5
6
|
|
|
6
7
|
let schema = {
|
|
7
8
|
_id: {type: String, default: uuidv4},
|
|
@@ -11,6 +12,7 @@ let schema = {
|
|
|
11
12
|
accuracy: {type: String, enum: Object.values(ZoneEnum.fenceAccuracy)},
|
|
12
13
|
radius: {
|
|
13
14
|
type: Number,
|
|
15
|
+
set: transformNumbertoDouble,
|
|
14
16
|
required: [true, 'radius is required. '],
|
|
15
17
|
validate: {
|
|
16
18
|
validator: function(v) {
|
package/package.json
CHANGED
package/schemas/Integration.js
CHANGED
|
@@ -9,6 +9,7 @@ const incentivioIntegrationSchema = require('./IncentivioIntegration')
|
|
|
9
9
|
const mparticleIntegrationSchema = require('./MparticleIntegration')
|
|
10
10
|
const klaviyoIntegrationSchema = require('./KlaviyoIntegration')
|
|
11
11
|
const doordashIntegrationSchema = require('./DoordashIntegration')
|
|
12
|
+
const ubereatsIntegrationSchema = require('./UberEatsIntegration')
|
|
12
13
|
|
|
13
14
|
function mParticleValidator(value) {
|
|
14
15
|
const { androidApiKey, iosApiKey, webApiKey } = value;
|
|
@@ -25,7 +26,8 @@ const IntegrationSchema = new mongoose.Schema({
|
|
|
25
26
|
attentive: { type: projectAttentiveIntegrationSchema },
|
|
26
27
|
incentivio: { type: incentivioIntegrationSchema },
|
|
27
28
|
klaviyo: { type: klaviyoIntegrationSchema },
|
|
28
|
-
doordash: { type: doordashIntegrationSchema }
|
|
29
|
+
doordash: { type: doordashIntegrationSchema },
|
|
30
|
+
uberEats: { type: ubereatsIntegrationSchema }
|
|
29
31
|
},{ _id : false });
|
|
30
32
|
|
|
31
33
|
module.exports = IntegrationSchema
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
let UberEatsIntegrationSchema = new mongoose.Schema({
|
|
4
|
+
enabled: {type: Boolean, required: true, default: false},
|
|
5
|
+
lastSyncedTime: {type: Date, default: Date.now, required: true}
|
|
6
|
+
}, {
|
|
7
|
+
_id: false
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
module.exports = UberEatsIntegrationSchema
|