@bluedot-innovation/models 2.0.0-alpha1 → 2.0.0-beta.1
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/.eslintrc.js +6 -0
- package/.gitlab-ci.yml +43 -0
- package/.npmignore +3 -0
- package/.nyc_output/295801a153bad60b994d5c6b5a8016d9.json +1 -0
- package/.nyc_output/2963e30f6030a94b16dd86e7b5594ebe.json +1 -0
- package/.nyc_output/5fc62324d665599db6649363a937708e.json +1 -0
- package/.nyc_output/95eec4b77e4566b36a6300f0cf8bea0b.json +1 -0
- package/Models.js +36 -10
- package/README.MD +36 -0
- package/__tests__/action/message/messageAction.data.json +5 -0
- package/__tests__/action/message/messageAction.rules.json +3 -0
- package/__tests__/action/message/messageAction.spec.js +61 -0
- package/__tests__/action/url/urlAction.data.json +4 -0
- package/__tests__/action/url/urlAction.rules.json +3 -0
- package/__tests__/action/url/urlAction.spec.js +62 -0
- package/__tests__/dailyStats/checkDailyStats.js +30 -0
- package/__tests__/filter/beacon/beaconFilter.data.json +1 -0
- package/__tests__/filter/beacon/beaconFilter.rules.json +3 -0
- package/__tests__/filter/beacon/beaconFilter.spec.js +1 -0
- package/__tests__/filter/bearing/bearingFilter.data.json +5 -0
- package/__tests__/filter/bearing/bearingFilter.rules.json +3 -0
- package/__tests__/filter/bearing/bearingFilter.spec.js +95 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.data.json +5 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.rules.json +3 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +62 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.data.json +5 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.rules.json +3 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +62 -0
- package/__tests__/filter/speed/speedFilter.data.json +5 -0
- package/__tests__/filter/speed/speedFilter.rules.json +3 -0
- package/__tests__/filter/speed/speedFilter.spec.js +73 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.data.json +5 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.rules.json +3 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +73 -0
- package/__tests__/geofeature/beacon/beacon.data.json +12 -0
- package/__tests__/geofeature/beacon/beacon.rules.json +13 -0
- package/__tests__/geofeature/beacon/beacon.spec.js +95 -0
- package/__tests__/geofeature/boundingBox/boundingBox.data.json +12 -0
- package/__tests__/geofeature/boundingBox/boundingBox.rules.json +3 -0
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +61 -0
- package/__tests__/geofeature/circle/circle.data.json +9 -0
- package/__tests__/geofeature/circle/circle.rules.json +3 -0
- package/__tests__/geofeature/circle/circle.spec.js +62 -0
- package/__tests__/geofeature/polygon/polygon.data.json +46 -0
- package/__tests__/geofeature/polygon/polygon.rules.json +3 -0
- package/__tests__/geofeature/polygon/polygon.spec.js +61 -0
- package/__tests__/geofeature/polyline/polyline.data.json +46 -0
- package/__tests__/geofeature/polyline/polyline.rules.json +3 -0
- package/__tests__/geofeature/polyline/polyline.spec.js +61 -0
- package/__tests__/monthlyStats/monthlyStats.data.json +29 -0
- package/__tests__/monthlyStats/monthlyStats.spec.js +40 -0
- package/__tests__/zone/zone.action.spec.js +50 -0
- package/__tests__/zone/zone.data.json +154 -0
- package/__tests__/zone/zone.filter.spec.js +50 -0
- package/__tests__/zone/zone.geofeatures.spec.js +74 -0
- package/__tests__/zone/zone.spec.js +98 -0
- package/models/AdminPortalUser.js +10 -11
- package/models/AdminUser.js +6 -5
- package/models/Application.js +31 -30
- package/models/Beacon.js +92 -78
- package/models/BeaconFilter.js +28 -12
- package/models/BearingFilter.js +46 -23
- package/models/BoundingBox.js +36 -20
- package/models/CalendarDateRangeFilter.js +34 -19
- package/models/Circle.js +33 -18
- package/models/Contract.js +37 -38
- package/models/Customer.js +31 -31
- package/models/CustomerLogin.js +9 -10
- package/models/DBEvent.js +13 -14
- package/models/DailyStats.js +28 -0
- package/models/DeviceRulesRequest.js +27 -28
- package/models/Fence.js +12 -13
- package/models/GeoFence.js +12 -14
- package/models/Geofeature.js +16 -18
- package/models/MessageAction.js +31 -16
- package/models/MonthlyStats.js +39 -0
- package/models/NotificationLogEntry.js +7 -8
- package/models/POILocation.js +6 -7
- package/models/POILookup.js +8 -9
- package/models/POIResult.js +7 -8
- package/models/PartnerCustomer.js +12 -13
- package/models/PartnerPasswordReset.js +8 -9
- package/models/PartnerUser.js +10 -11
- package/models/Partners.js +11 -12
- package/models/PercentageCrossedFilter.js +30 -15
- package/models/Polygon.js +34 -19
- package/models/Polyline.js +35 -19
- package/models/RuleRequestAggregation.js +14 -15
- package/models/SimpleCheckInZone.js +21 -21
- package/models/SingleUseToken.js +7 -8
- package/models/SpeedFilter.js +39 -19
- package/models/TestDevice.js +11 -12
- package/models/TestDeviceCluster.js +9 -10
- package/models/TestInstance.js +9 -10
- package/models/TestScenario.js +9 -10
- package/models/TimeOfDayRange.js +16 -16
- package/models/TimeOfDayRangeFilter.js +36 -18
- package/models/UrlAction.js +54 -0
- package/models/Zone.js +85 -273
- package/models/ZoneUIState.js +18 -18
- package/package-lock.json +3503 -0
- package/package.json +20 -8
- package/schemas/Point.js +10 -13
- package/__tests__/zone/checkActions.js +0 -64
- package/__tests__/zone/checkAppId.js +0 -41
- package/__tests__/zone/checkBeacon.js +0 -46
- package/__tests__/zone/checkBearingFitler.js +0 -48
- package/__tests__/zone/checkBoundingBox.js +0 -44
- package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +0 -48
- package/__tests__/zone/checkCircle.js +0 -41
- package/__tests__/zone/checkMRT.js +0 -46
- package/__tests__/zone/checkPercentageCrossedFitler.js +0 -48
- package/__tests__/zone/checkPolygon.js +0 -78
- package/__tests__/zone/checkPolyline.js +0 -78
- package/__tests__/zone/checkSpeedFitler.js +0 -48
- package/__tests__/zone/checkTimeOfDayRangeFitler.js +0 -48
- package/models/URLAction.js +0 -34
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let BoundingBoxModel = require('../../../models/BoundingBox').BoundingBox(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
|
|
14
|
+
let rules = require('./boundingBox.rules.json')
|
|
15
|
+
|
|
16
|
+
let boundingBox
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
boundingBox = JSON.parse(JSON.stringify(require('./boundingBox.data.json')))
|
|
20
|
+
})
|
|
21
|
+
testCase('BoundingBox', () => {
|
|
22
|
+
testCase('Valid BoundingBox', () => {
|
|
23
|
+
assertions('should validate a valid boundingBox ', (done) => {
|
|
24
|
+
let BoundingBox = new BoundingBoxModel(boundingBox)
|
|
25
|
+
BoundingBox.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
testCase('Invalid BoundingBox', () => {
|
|
34
|
+
assertions('should not validate a boundingBox with invalid BoundingBox', (done) => {
|
|
35
|
+
delete boundingBox[rules.requiredFields[0]]
|
|
36
|
+
let BoundingBox = new BoundingBoxModel(boundingBox)
|
|
37
|
+
BoundingBox.validate((err, res) => {
|
|
38
|
+
assert.exists(err, 'err object should exist')
|
|
39
|
+
assert.isObject(err)
|
|
40
|
+
done()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
testCase('check each required property of the model and validate that it is present', () => {
|
|
44
|
+
let requiredFields = rules.requiredFields
|
|
45
|
+
requiredFields.map((i) => {
|
|
46
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
47
|
+
// delete i from geofeatures' boundingBox child
|
|
48
|
+
delete boundingBox[i]
|
|
49
|
+
let BoundingBox = new BoundingBoxModel(boundingBox)
|
|
50
|
+
BoundingBox.validate((err, res) => {
|
|
51
|
+
assert.notExists(res)
|
|
52
|
+
assert.exists(err, 'err object should exist')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
55
|
+
done()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let CircleModel = require('../../../models/Circle').Circle(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let beforeEach = require('mocha').beforeEach
|
|
12
|
+
|
|
13
|
+
let rules = require('./circle.rules.json')
|
|
14
|
+
|
|
15
|
+
let circle
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
circle = JSON.parse(JSON.stringify(require('./circle.data.json')))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
testCase('Circle', () => {
|
|
22
|
+
testCase('Valid Circle', () => {
|
|
23
|
+
assertions('should validate zone with Circle ', (done) => {
|
|
24
|
+
let Circle = new CircleModel(circle)
|
|
25
|
+
Circle.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
testCase('Invalid Circle', () => {
|
|
34
|
+
assertions('should not validate a Circle with no radius', (done) => {
|
|
35
|
+
delete circle.radius
|
|
36
|
+
let Circle = new CircleModel(circle)
|
|
37
|
+
Circle.validate((err, res) => {
|
|
38
|
+
assert.exists(err, 'err object should exist')
|
|
39
|
+
assert.isObject(err)
|
|
40
|
+
done()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
testCase('recursive property check', () => {
|
|
45
|
+
let requiredFields = rules.requiredFields
|
|
46
|
+
requiredFields.map((i) => {
|
|
47
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
48
|
+
// delete i from geofeatures' circle child
|
|
49
|
+
delete circle[i]
|
|
50
|
+
let Circle = new CircleModel(circle)
|
|
51
|
+
Circle.validate((err, res) => {
|
|
52
|
+
assert.notExists(res)
|
|
53
|
+
assert.exists(err, 'err object should exist')
|
|
54
|
+
assert.isObject(err)
|
|
55
|
+
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
56
|
+
done()
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "polygon",
|
|
3
|
+
"name": "Test Polygon",
|
|
4
|
+
"vertices": [
|
|
5
|
+
{
|
|
6
|
+
"latitude": -37.81902680201739,
|
|
7
|
+
"longitude": 144.9821037054062
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"latitude": -37.8196878692931,
|
|
11
|
+
"longitude": 144.98161554336548
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"latitude": -37.82052267015026,
|
|
15
|
+
"longitude": 144.9816906452179
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"latitude": -37.82128118660006,
|
|
19
|
+
"longitude": 144.98312830924988
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"latitude": -37.82102693614463,
|
|
23
|
+
"longitude": 144.98458743095398
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"latitude": -37.820196378553405,
|
|
27
|
+
"longitude": 144.98524725437164
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"latitude": -37.81895899991077,
|
|
31
|
+
"longitude": 144.9847161769867
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"latitude": -37.81865812731128,
|
|
35
|
+
"longitude": 144.9839222431183
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"latitude": -37.81866660261256,
|
|
39
|
+
"longitude": 144.98308539390564
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"latitude": -37.81902680201739,
|
|
43
|
+
"longitude": 144.9821037054062
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let PolygonModel = require('../../../models/Polygon').Polygon(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
|
|
14
|
+
let rules = require('./polygon.rules.json')
|
|
15
|
+
|
|
16
|
+
let polygon
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
polygon = JSON.parse(JSON.stringify(require('./polygon.data.json')))
|
|
20
|
+
})
|
|
21
|
+
testCase('Polygon', () => {
|
|
22
|
+
testCase('Valid Polygon', () => {
|
|
23
|
+
assertions('should validate a valid polygon ', (done) => {
|
|
24
|
+
let Polygon = new PolygonModel(polygon)
|
|
25
|
+
Polygon.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
testCase('Invalid Polygon', () => {
|
|
34
|
+
assertions('should not validate a polygon with invalid Polygon', (done) => {
|
|
35
|
+
delete polygon[rules.requiredFields[0]]
|
|
36
|
+
let Polygon = new PolygonModel(polygon)
|
|
37
|
+
Polygon.validate((err, res) => {
|
|
38
|
+
assert.exists(err, 'err object should exist')
|
|
39
|
+
assert.isObject(err)
|
|
40
|
+
done()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
testCase('check each required property of the model and validate that it is present', () => {
|
|
44
|
+
let requiredFields = rules.requiredFields
|
|
45
|
+
requiredFields.map((i) => {
|
|
46
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
47
|
+
// delete i from geofeatures' polygon child
|
|
48
|
+
delete polygon[i]
|
|
49
|
+
let Polygon = new PolygonModel(polygon)
|
|
50
|
+
Polygon.validate((err, res) => {
|
|
51
|
+
assert.notExists(res)
|
|
52
|
+
assert.exists(err, 'err object should exist')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
55
|
+
done()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "polyline",
|
|
3
|
+
"name": "Test Polygon",
|
|
4
|
+
"vertices": [
|
|
5
|
+
{
|
|
6
|
+
"latitude": -37.81902680201739,
|
|
7
|
+
"longitude": 144.9821037054062
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"latitude": -37.8196878692931,
|
|
11
|
+
"longitude": 144.98161554336548
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"latitude": -37.82052267015026,
|
|
15
|
+
"longitude": 144.9816906452179
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"latitude": -37.82128118660006,
|
|
19
|
+
"longitude": 144.98312830924988
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"latitude": -37.82102693614463,
|
|
23
|
+
"longitude": 144.98458743095398
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"latitude": -37.820196378553405,
|
|
27
|
+
"longitude": 144.98524725437164
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"latitude": -37.81895899991077,
|
|
31
|
+
"longitude": 144.9847161769867
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"latitude": -37.81865812731128,
|
|
35
|
+
"longitude": 144.9839222431183
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"latitude": -37.81866660261256,
|
|
39
|
+
"longitude": 144.98308539390564
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"latitude": -37.81902680201739,
|
|
43
|
+
"longitude": 144.9821037054062
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let PolylineModel = require('../../../models/Polyline').Polyline(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
|
|
14
|
+
let rules = require('./polyline.rules.json')
|
|
15
|
+
|
|
16
|
+
let polyline
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
polyline = JSON.parse(JSON.stringify(require('./polyline.data.json')))
|
|
20
|
+
})
|
|
21
|
+
testCase('Polyline', () => {
|
|
22
|
+
testCase('Valid Polyline', () => {
|
|
23
|
+
assertions('should validate a valid polyline ', (done) => {
|
|
24
|
+
let Polyline = new PolylineModel(polyline)
|
|
25
|
+
Polyline.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
testCase('Invalid Polyline', () => {
|
|
34
|
+
assertions('should not validate a polyline with invalid polyline', (done) => {
|
|
35
|
+
delete polyline[rules.requiredFields[0]]
|
|
36
|
+
let Polyline = new PolylineModel(polyline)
|
|
37
|
+
Polyline.validate((err, res) => {
|
|
38
|
+
assert.exists(err, 'err object should exist')
|
|
39
|
+
assert.isObject(err)
|
|
40
|
+
done()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
testCase('check each required property of the model and validate that it is present', () => {
|
|
44
|
+
let requiredFields = rules.requiredFields
|
|
45
|
+
requiredFields.map((i) => {
|
|
46
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
47
|
+
// delete i from geofeatures' polyline child
|
|
48
|
+
delete polyline[i]
|
|
49
|
+
let Polyline = new PolylineModel(polyline)
|
|
50
|
+
Polyline.validate((err, res) => {
|
|
51
|
+
assert.notExists(res)
|
|
52
|
+
assert.exists(err, 'err object should exist')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
55
|
+
done()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_id": "709aa8f4-3c53-496d-8824-73cb73ce6963",
|
|
3
|
+
"creationTime": "2017-12-31T23:17:30.658Z",
|
|
4
|
+
"monthOfCount": "2017-12-31T23:17:30.658Z",
|
|
5
|
+
"customerId": "313ff409-0bb7-4af5-8cc9-9d0ff3631b9f",
|
|
6
|
+
"totalMonthlyUsers": 23,
|
|
7
|
+
"applications": [
|
|
8
|
+
{
|
|
9
|
+
"applicationId": "d49fdf10-3744-462c-84f8-abad444d7044",
|
|
10
|
+
"monthlyUsers": 3
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"applicationId": "d26b75ad-42ca-401c-b526-d745105886cd",
|
|
14
|
+
"monthlyUsers": 12
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"applicationId": "6a2d898f-6894-41b8-8e7b-3445872f27d3",
|
|
18
|
+
"monthlyUsers": 3
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"applicationId": "df9dd8a9-e6f1-417b-88c4-6d314a64ab80",
|
|
22
|
+
"monthlyUsers": 4
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"applicationId": "ab45514e-0d66-47dd-9508-b19c8cad1c4e",
|
|
26
|
+
"monthlyUsers": 1
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let MonthlyStatsModel = require('../../models/MonthlyStats')(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
|
|
14
|
+
let monthlyStats
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
monthlyStats = JSON.parse(JSON.stringify(require('./monthlyStats.data.json')))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
testCase('MonthlyStats', () => {
|
|
21
|
+
testCase('Valid MonthlyStats document', () => {
|
|
22
|
+
assertions('should validate a valid MonthlyStats document ', (done) => {
|
|
23
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
24
|
+
MonthlyStats.validate((err, res) => {
|
|
25
|
+
assert.notExists(res)
|
|
26
|
+
assert(err === null, 'err should equals null')
|
|
27
|
+
done()
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
assertions('should accept a valid customerId', (done) => {
|
|
31
|
+
monthlyStats.customerId = '23a01af0-232a-4518-9c0e-323fb773f5ef'
|
|
32
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
33
|
+
MonthlyStats.validate((err, res) => {
|
|
34
|
+
assert.notExists(res)
|
|
35
|
+
assert(err === null, 'err should equals null')
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let ZoneModel = require('../../models/Zone').Zone(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
let assert = chai.assert
|
|
10
|
+
let mocha = require('mocha')
|
|
11
|
+
let beforeEach = mocha.beforeEach
|
|
12
|
+
|
|
13
|
+
let zone
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
zone = JSON.parse(JSON.stringify(require('./zone.data.json')))
|
|
17
|
+
// remove filters as it's not tested
|
|
18
|
+
delete zone.filters
|
|
19
|
+
// remove all but 1 geofeatures as geofeatures are required
|
|
20
|
+
zone.geofeatures = zone.geofeatures.filter(x => x.type.match(/circle/i))
|
|
21
|
+
// remove customData
|
|
22
|
+
delete zone.customData
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
testCase('Zone - Action', () => {
|
|
26
|
+
testCase('Valid Zone - Action', () => {
|
|
27
|
+
assertions('should not throw an error when a valid action is instantiated within a zone', (done) => {
|
|
28
|
+
let Zone = new ZoneModel(zone)
|
|
29
|
+
Zone.validate((err, res) => {
|
|
30
|
+
assert.notExists(res)
|
|
31
|
+
assert(err === null, 'err equals null')
|
|
32
|
+
done()
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
testCase('Invalid Zone - Action', () => {
|
|
38
|
+
assertions('should throw an error when an invalid action is instantiated within a zone', (done) => {
|
|
39
|
+
delete zone.actions[1].url
|
|
40
|
+
let Zone = new ZoneModel(zone)
|
|
41
|
+
Zone.validate((err, res) => {
|
|
42
|
+
assert.exists(err, 'err object should exist')
|
|
43
|
+
assert.isObject(err)
|
|
44
|
+
assert('actions.1.url' in err.errors)
|
|
45
|
+
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
46
|
+
done()
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "TDD zone",
|
|
3
|
+
"minimumRetriggerTime": "60",
|
|
4
|
+
"checkout": true,
|
|
5
|
+
"applicationId": "c7058934-f1e6-4176-8730-a0bd28e8e0a9",
|
|
6
|
+
"customData": [
|
|
7
|
+
{
|
|
8
|
+
"name1": "A Custom action1"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name2": "A Custom action2"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"actions": [
|
|
15
|
+
{
|
|
16
|
+
"type": "message",
|
|
17
|
+
"message": "hello",
|
|
18
|
+
"title": "hello"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "url",
|
|
22
|
+
"url": "https://www.google.com"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"filters": [
|
|
26
|
+
{
|
|
27
|
+
"type" : "calendarDateRange",
|
|
28
|
+
"startDate" : "2017-11-14",
|
|
29
|
+
"endDate" : "2017-11-15"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"geofeatures": [{
|
|
33
|
+
"type": "beacon",
|
|
34
|
+
"name": "create beacon",
|
|
35
|
+
"proximityUUID": "23a01af0-232a-4518-9c0e-323fb773f5ef",
|
|
36
|
+
"latitude": -37.8159544565362,
|
|
37
|
+
"longitude": 144.9723565578461,
|
|
38
|
+
"beaconType": "Both",
|
|
39
|
+
"major": 10000,
|
|
40
|
+
"phone": 123123123123,
|
|
41
|
+
"minor": 56466,
|
|
42
|
+
"txPower": -77,
|
|
43
|
+
"macAddress": "01:17:c5:31:84:19"
|
|
44
|
+
},{
|
|
45
|
+
"type": "circle",
|
|
46
|
+
"name": "Test Circle",
|
|
47
|
+
"radius": 10,
|
|
48
|
+
"center": {
|
|
49
|
+
"latitude": -37.8159544565362,
|
|
50
|
+
"longitude": 144.9723565578461
|
|
51
|
+
}
|
|
52
|
+
},{
|
|
53
|
+
"type": "boundingBox",
|
|
54
|
+
"name": "Test BoundingBox",
|
|
55
|
+
"northEast": {
|
|
56
|
+
"latitude": -37.81794619852986,
|
|
57
|
+
"longitude": 144.97999548912048
|
|
58
|
+
},
|
|
59
|
+
"southWest": {
|
|
60
|
+
"latitude": -37.81846319511329,
|
|
61
|
+
"longitude": 144.97921228408813
|
|
62
|
+
}
|
|
63
|
+
},{
|
|
64
|
+
"type": "polygon",
|
|
65
|
+
"name": "Test Polygon",
|
|
66
|
+
"vertices": [
|
|
67
|
+
{
|
|
68
|
+
"latitude": -37.81902680201739,
|
|
69
|
+
"longitude": 144.9821037054062
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"latitude": -37.8196878692931,
|
|
73
|
+
"longitude": 144.98161554336548
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"latitude": -37.82052267015026,
|
|
77
|
+
"longitude": 144.9816906452179
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"latitude": -37.82128118660006,
|
|
81
|
+
"longitude": 144.98312830924988
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"latitude": -37.82102693614463,
|
|
85
|
+
"longitude": 144.98458743095398
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"latitude": -37.820196378553405,
|
|
89
|
+
"longitude": 144.98524725437164
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"latitude": -37.81895899991077,
|
|
93
|
+
"longitude": 144.9847161769867
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"latitude": -37.81865812731128,
|
|
97
|
+
"longitude": 144.9839222431183
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"latitude": -37.81866660261256,
|
|
101
|
+
"longitude": 144.98308539390564
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"latitude": -37.81902680201739,
|
|
105
|
+
"longitude": 144.9821037054062
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},{
|
|
109
|
+
"type": "polyline",
|
|
110
|
+
"name": "Test Polygon",
|
|
111
|
+
"vertices": [
|
|
112
|
+
{
|
|
113
|
+
"latitude": -37.81902680201739,
|
|
114
|
+
"longitude": 144.9821037054062
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"latitude": -37.8196878692931,
|
|
118
|
+
"longitude": 144.98161554336548
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"latitude": -37.82052267015026,
|
|
122
|
+
"longitude": 144.9816906452179
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"latitude": -37.82128118660006,
|
|
126
|
+
"longitude": 144.98312830924988
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"latitude": -37.82102693614463,
|
|
130
|
+
"longitude": 144.98458743095398
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"latitude": -37.820196378553405,
|
|
134
|
+
"longitude": 144.98524725437164
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"latitude": -37.81895899991077,
|
|
138
|
+
"longitude": 144.9847161769867
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"latitude": -37.81865812731128,
|
|
142
|
+
"longitude": 144.9839222431183
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"latitude": -37.81866660261256,
|
|
146
|
+
"longitude": 144.98308539390564
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"latitude": -37.81902680201739,
|
|
150
|
+
"longitude": 144.9821037054062
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}]
|
|
154
|
+
}
|