@bluedot-innovation/models 3.1.1 → 4.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.
Files changed (160) hide show
  1. package/Models.js +10 -55
  2. package/models/AdminPortalUser.js +11 -10
  3. package/models/AdminUser.js +10 -0
  4. package/models/Application.js +38 -0
  5. package/models/ApplicationNotificationAction.js +30 -0
  6. package/models/ApplicationUsage.js +11 -0
  7. package/models/Beacon.js +32 -84
  8. package/models/BeaconFilter.js +23 -0
  9. package/models/BearingFilter.js +19 -0
  10. package/models/BoundingBox.js +17 -0
  11. package/models/Circle.js +21 -0
  12. package/models/ConfigurationParameters.js +20 -0
  13. package/models/Contract.js +38 -37
  14. package/models/Customer.js +38 -0
  15. package/models/CustomerLogin.js +10 -9
  16. package/models/DBEvent.js +14 -13
  17. package/models/DailyStats.js +7 -7
  18. package/models/DateRangeFilter.js +20 -0
  19. package/models/DeviceRulesRequest.js +28 -27
  20. package/models/Fence.js +21 -0
  21. package/models/FormattedBeacon.js +16 -0
  22. package/models/FormattedCircle.js +12 -0
  23. package/models/FormattedConditions.js +11 -0
  24. package/models/FormattedDateRange.js +11 -0
  25. package/models/FormattedPercentageCrossed.js +12 -0
  26. package/models/FormattedPoint.js +10 -0
  27. package/models/FormattedPolygon.js +11 -0
  28. package/models/FormattedPolyline.js +11 -0
  29. package/models/FormattedRectangle.js +12 -0
  30. package/models/FormattedTimeActive.js +17 -0
  31. package/models/FormattedZone.js +28 -0
  32. package/models/GeoFence.js +23 -0
  33. package/models/Geofeature.js +26 -0
  34. package/models/MessageAction.js +26 -28
  35. package/models/MonthlyStats.js +19 -35
  36. package/models/NotificationLogEntry.js +8 -7
  37. package/models/POILocation.js +7 -6
  38. package/models/POILookup.js +9 -8
  39. package/models/POIResult.js +8 -7
  40. package/models/PartnerCustomer.js +13 -12
  41. package/models/PartnerPasswordReset.js +9 -8
  42. package/models/PartnerUser.js +11 -10
  43. package/models/Partners.js +12 -11
  44. package/models/PercentageCrossedFilter.js +19 -0
  45. package/models/Point.js +20 -0
  46. package/models/Polygon.js +18 -0
  47. package/models/Polyline.js +18 -0
  48. package/models/PropertyMapping.js +17 -0
  49. package/models/Reference.js +19 -0
  50. package/models/RuleRequestAggregation.js +17 -33
  51. package/models/SequenceFilter.js +18 -0
  52. package/models/SimpleCheckInZone.js +29 -0
  53. package/models/SingleUseToken.js +8 -7
  54. package/models/SoundAction.js +28 -0
  55. package/models/SpeedFilter.js +19 -0
  56. package/models/TestDevice.js +12 -11
  57. package/models/TestDeviceCluster.js +10 -9
  58. package/models/TestInstance.js +10 -9
  59. package/models/TestScenario.js +10 -9
  60. package/models/TimeOfDayRange.js +16 -16
  61. package/models/TimeOfDayRangeFilter.js +19 -0
  62. package/models/URLAction.js +31 -0
  63. package/models/VibrationAction.js +28 -0
  64. package/models/ZoneUIState.js +18 -18
  65. package/models/property.js +25 -0
  66. package/package-lock.json.bak +170 -0
  67. package/package.json +6 -30
  68. package/.eslintrc.js +0 -42
  69. package/.gitlab-ci.yml +0 -43
  70. package/CHANGELOG.md +0 -152
  71. package/README.MD +0 -36
  72. package/__tests__/account/account.data.json +0 -12
  73. package/__tests__/account/account.rules.js +0 -8
  74. package/__tests__/account/account.spec.js +0 -83
  75. package/__tests__/action/message/messageAction.data.json +0 -5
  76. package/__tests__/action/message/messageAction.rules.json +0 -3
  77. package/__tests__/action/message/messageAction.spec.js +0 -61
  78. package/__tests__/action/url/urlAction.data.json +0 -4
  79. package/__tests__/action/url/urlAction.rules.json +0 -3
  80. package/__tests__/action/url/urlAction.spec.js +0 -74
  81. package/__tests__/beacon/beacon.data.json +0 -15
  82. package/__tests__/beacon/beacon.rules.json +0 -13
  83. package/__tests__/beacon/beacon.spec.js +0 -104
  84. package/__tests__/condition/beacon/beaconFilter.data.json +0 -1
  85. package/__tests__/condition/beacon/beaconFilter.rules.json +0 -3
  86. package/__tests__/condition/beacon/beaconFilter.spec.js +0 -1
  87. package/__tests__/condition/dayRange/dayRange.data.json +0 -5
  88. package/__tests__/condition/dayRange/dayRange.rules.json +0 -3
  89. package/__tests__/condition/dayRange/dayRange.spec.js +0 -74
  90. package/__tests__/condition/percentageCrossed/travelPath.data.json +0 -5
  91. package/__tests__/condition/percentageCrossed/travelPath.rules.json +0 -3
  92. package/__tests__/condition/percentageCrossed/travelPath.spec.js +0 -62
  93. package/__tests__/condition/speed/speed.data.json +0 -5
  94. package/__tests__/condition/speed/speed.rules.json +0 -3
  95. package/__tests__/condition/speed/speed.spec.js +0 -73
  96. package/__tests__/condition/timeActive/timeActive.data.json +0 -5
  97. package/__tests__/condition/timeActive/timeActive.rules.json +0 -7
  98. package/__tests__/condition/timeActive/timeActive.spec.js +0 -94
  99. package/__tests__/condition/travelDirection/travelDirection.data.json +0 -5
  100. package/__tests__/condition/travelDirection/travelDirection.rules.json +0 -3
  101. package/__tests__/condition/travelDirection/travelDirection.spec.js +0 -132
  102. package/__tests__/dailyStats/checkDailyStats.js +0 -31
  103. package/__tests__/geofeature/boundingBox/boundingBox.data.json +0 -12
  104. package/__tests__/geofeature/boundingBox/boundingBox.rules.json +0 -3
  105. package/__tests__/geofeature/boundingBox/boundingBox.spec.js +0 -78
  106. package/__tests__/geofeature/circle/circle.data.json +0 -9
  107. package/__tests__/geofeature/circle/circle.rules.json +0 -3
  108. package/__tests__/geofeature/circle/circle.spec.js +0 -71
  109. package/__tests__/geofeature/geoline/geoline.data.json +0 -46
  110. package/__tests__/geofeature/geoline/geoline.rules.json +0 -3
  111. package/__tests__/geofeature/geoline/geoline.spec.js +0 -70
  112. package/__tests__/geofeature/polygon/polygon.data.json +0 -46
  113. package/__tests__/geofeature/polygon/polygon.rules.json +0 -3
  114. package/__tests__/geofeature/polygon/polygon.spec.js +0 -127
  115. package/__tests__/geofeature/zoneBeacon/zoneBeacon.data.json +0 -16
  116. package/__tests__/geofeature/zoneBeacon/zoneBeacon.rules.json +0 -13
  117. package/__tests__/geofeature/zoneBeacon/zoneBeacon.spec.js +0 -62
  118. package/__tests__/monthlyStats/monthlyStats.data.json +0 -29
  119. package/__tests__/monthlyStats/monthlyStats.spec.js +0 -66
  120. package/__tests__/project/project.data.json +0 -18
  121. package/__tests__/project/project.rules.json +0 -9
  122. package/__tests__/project/project.spec.js +0 -81
  123. package/__tests__/ruleRequestAggregation/ruleRequestAggregation.data.json +0 -8
  124. package/__tests__/ruleRequestAggregation/ruleRequestAggregation.spec.js +0 -69
  125. package/__tests__/setup.js +0 -7
  126. package/__tests__/user/user.data.js +0 -19
  127. package/__tests__/user/user.rules.js +0 -8
  128. package/__tests__/user/user.spec.js +0 -130
  129. package/__tests__/utils/utils.spec.js +0 -24
  130. package/__tests__/zone/zone.action.spec.js +0 -50
  131. package/__tests__/zone/zone.condition.spec.js +0 -76
  132. package/__tests__/zone/zone.data.json +0 -157
  133. package/__tests__/zone/zone.geofeatures.spec.js +0 -75
  134. package/__tests__/zone/zone.spec.js +0 -134
  135. package/constants/errorMessages.js +0 -2
  136. package/helpers.js +0 -102
  137. package/models/Account.js +0 -50
  138. package/models/Project.js +0 -55
  139. package/models/UrlAction.js +0 -46
  140. package/models/User.js +0 -61
  141. package/models/Zone.js +0 -123
  142. package/models/conditions/DayRange.js +0 -52
  143. package/models/conditions/Speed.js +0 -42
  144. package/models/conditions/TimeActive.js +0 -50
  145. package/models/conditions/TravelDirection.js +0 -67
  146. package/models/conditions/TravelPath.js +0 -36
  147. package/models/geofeatures/BoundingBox.js +0 -44
  148. package/models/geofeatures/Circle.js +0 -39
  149. package/models/geofeatures/Geoline.js +0 -34
  150. package/models/geofeatures/Polygon.js +0 -45
  151. package/models/geofeatures/ZoneBeacon.js +0 -28
  152. package/schemas/MultiLineStringGeometry.js +0 -14
  153. package/schemas/Point.js +0 -13
  154. package/schemas/PointGeometry.js +0 -14
  155. package/schemas/PolygonGeometry.js +0 -14
  156. package/schemas/ProjectPermission.js +0 -21
  157. package/schemas/Webhook.js +0 -22
  158. package/utils/index.js +0 -39
  159. package/validators/checkDistanceBetweenVertices.js +0 -21
  160. package/yarn.lock +0 -2796
@@ -1,61 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let MessageActionModel = require('../../../Models').MessageAction(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
- let rules = require('./messageAction.rules.json')
14
-
15
- let messageAction
16
-
17
- beforeEach(() => {
18
- messageAction = JSON.parse(JSON.stringify(require('./messageAction.data.json')))
19
- })
20
-
21
- testCase('MessageAction', () => {
22
- testCase('Valid MessageAction', () => {
23
- assertions('should validate a valid messageAction ', (done) => {
24
- let MessageAction = new MessageActionModel(messageAction)
25
- MessageAction.validate((err, res) => {
26
- assert.notExists(res)
27
- assert(err === null, 'err should equals null')
28
- done()
29
- })
30
- })
31
- })
32
-
33
- testCase('Invalid MessageAction', () => {
34
- assertions('should not validate a messageAction with invalid MessageAction', (done) => {
35
- delete messageAction[rules.requiredFields[0]]
36
- let MessageAction = new MessageActionModel(messageAction)
37
- MessageAction.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' messageAction child
48
- delete messageAction[i]
49
- let MessageAction = new MessageActionModel(messageAction)
50
- MessageAction.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 ${i} property`)
55
- done()
56
- })
57
- })
58
- })
59
- })
60
- })
61
- })
@@ -1,4 +0,0 @@
1
- {
2
- "type": "url",
3
- "url": "https://www.google.com"
4
- }
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields":["url"]
3
- }
@@ -1,74 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let UrlactionModel = require('../../../Models').UrlAction(mongoose)
6
- let UrlactionModelBuiltInMongoose = require('../../../Models').UrlAction()
7
- let testCase = require('mocha').describe
8
- let assertions = require('mocha').it
9
- let chai = require('chai')
10
-
11
- let assert = chai.assert
12
- let mocha = require('mocha')
13
- let beforeEach = mocha.beforeEach
14
-
15
- let rules = require('./urlAction.rules.json')
16
-
17
- let urlaction
18
-
19
- beforeEach(() => {
20
- urlaction = JSON.parse(JSON.stringify(require('./urlAction.data.json')))
21
- })
22
-
23
- testCase('Urlaction', () => {
24
- testCase('Valid Urlaction', () => {
25
- assertions('should validate a valid urlaction ', (done) => {
26
- let Urlaction = new UrlactionModel(urlaction)
27
- Urlaction.validate((err, res) => {
28
- assert.notExists(res)
29
- assert(err === null, 'err should equals null')
30
- done()
31
- })
32
- })
33
- })
34
-
35
- testCase('Valid Urlaction (Built in mongoose)', () => {
36
- assertions('should validate a valid urlaction ', (done) => {
37
- let Urlaction = new UrlactionModelBuiltInMongoose(urlaction)
38
- Urlaction.validate((err, res) => {
39
- assert.notExists(res)
40
- assert(err === null, 'err should equals null')
41
- done()
42
- })
43
- })
44
- })
45
-
46
- testCase('Invalid Urlaction', () => {
47
- assertions('should not validate a urlaction with invalid Urlaction', (done) => {
48
- delete urlaction[rules.requiredFields[0]]
49
- let Urlaction = new UrlactionModel(urlaction)
50
- Urlaction.validate((err, res) => {
51
- assert.exists(err, 'err object should exist')
52
- assert.isObject(err)
53
- done()
54
- })
55
- })
56
- testCase('check each required property of the model and validate that it is present', () => {
57
- let requiredFields = rules.requiredFields
58
- requiredFields.map((i) => {
59
- assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
60
- // delete i from geofeatures' urlaction child
61
- delete urlaction[i]
62
- let Urlaction = new UrlactionModel(urlaction)
63
- Urlaction.validate((err, res) => {
64
- assert.notExists(res)
65
- assert.exists(err, 'err object should exist')
66
- assert.isObject(err)
67
- assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
68
- done()
69
- })
70
- })
71
- })
72
- })
73
- })
74
- })
@@ -1,15 +0,0 @@
1
- {
2
- "type": "beacon",
3
- "name": "create beacon",
4
- "proximityUUID": "23a01af0-232a-4518-9c0e-323fb773f5ef",
5
- "location": {
6
- "latitude": -37.8159544565362,
7
- "longitude": 144.9723565578461
8
- },
9
- "beaconType": "Both",
10
- "major": 10000,
11
- "minor": 56466,
12
- "txPower": -77,
13
- "macAddress": "01:17:c5:31:84:19",
14
- "accountId": "90a2ed18-86be-48e7-948b-393b8b679ef6"
15
- }
@@ -1,13 +0,0 @@
1
- {
2
- "requiredFields":["name", "location", "beaconType"],
3
- "dependentRequiredFields": [
4
- {
5
- "property": "beaconType",
6
- "pairings": [
7
- {"value": "ios", "requiredFields": ["proximityUUID", "major", "minor"]},
8
- {"value": "android", "requiredFields": ["macAddress"]},
9
- {"value": "both", "requiredFields": ["proximityUUID", "major", "minor", "macAddress"]}
10
- ]
11
- }
12
- ]
13
- }
@@ -1,104 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let BeaconModel = require('../../Models').Beacon(mongoose)
6
- let describe = require('mocha').describe
7
- let it = 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('./beacon.rules.json')
15
-
16
- let beacon
17
-
18
- beforeEach(() => {
19
- beacon = JSON.parse(JSON.stringify(require('./beacon.data.json')))
20
- })
21
-
22
- describe('Beacon', () => {
23
- describe('Valid Beacon', () => {
24
- it('should validate a valid beacon', (done) => {
25
- const Beacon = new BeaconModel(beacon)
26
- Beacon.validate((err, res) => {
27
- assert.notExists(res)
28
- assert(err === null, 'err should equal null')
29
- done()
30
- })
31
- })
32
- })
33
-
34
- describe('Invalid Beacon', () => {
35
- it('should not validate a beacon with invalid Beacon', (done) => {
36
- delete beacon[rules.requiredFields[0]]
37
- let Beacon = new BeaconModel(beacon)
38
- Beacon.validate((err, res) => {
39
- assert.exists(err, 'err object should exist')
40
- assert.isObject(err)
41
- done()
42
- })
43
- })
44
-
45
- describe('check each required property of the model and validate that it is present', (done) => {
46
- let dependentRequiredFields = rules.dependentRequiredFields
47
- dependentRequiredFields.forEach((parent) => {
48
- parent.pairings.forEach((i) => {
49
- i.requiredFields.forEach((field) => {
50
- it(`should throw an error with property '${parent.property}' if '${i.value}' is selected and '${field}' is invalid`, (done) => {
51
- // delete beacon[field] i.e. txPower from beacon
52
- delete beacon[field]
53
- // set required dependent field property
54
- beacon[parent.property] = i.value
55
- let Beacon = new BeaconModel(beacon)
56
- Beacon.validate((err, res) => {
57
- assert.notExists(res)
58
- assert.exists(err, 'err object should exist')
59
- assert.isObject(err)
60
- assert.nestedProperty(err, `errors.${parent.property}`, `error should have a ${parent.property} property`)
61
- done()
62
- })
63
- })
64
- })
65
- })
66
- })
67
- })
68
-
69
- describe('check each required property of the model and validate that it is present', () => {
70
- let requiredFields = rules.requiredFields
71
- requiredFields.forEach((requiredField) => {
72
- it(`should throw an error with property '${requiredField}' if '${requiredField}' is not present`, (done) => {
73
- // delete i from geofeatures' beacon child
74
- delete beacon[requiredField]
75
- let Beacon = new BeaconModel(beacon)
76
- Beacon.validate((err, res) => {
77
- assert.notExists(res)
78
- assert.exists(err, 'err object should exist')
79
- assert.isObject(err)
80
- assert.nestedProperty(err, `errors.${requiredField}`, `error should have a ${requiredField} property`)
81
- done()
82
- })
83
- })
84
- })
85
- })
86
-
87
- describe('should fail validation if the beaconType does not match the enum', () => {
88
- const failingBeaconTypes = ['ios', 'iOS', 'android', 'ANDROID', 'both', 'BOTH'];
89
-
90
- failingBeaconTypes.forEach(beaconType => {
91
- it(beaconType, (done) => {
92
- let Beacon = new BeaconModel(beacon);
93
- Beacon.beaconType = beaconType;
94
-
95
- Beacon.validate((err, res) => {
96
- assert.exists(err)
97
- assert.match(err, /(is not a valid enum value)/i)
98
- done()
99
- })
100
- })
101
- })
102
- })
103
- })
104
- })
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields":[]
3
- }
@@ -1 +0,0 @@
1
- // not implemented. not sure if required
@@ -1,5 +0,0 @@
1
- {
2
- "type" : "dayRange",
3
- "startDate" : "2017-11-14",
4
- "endDate" : "2030-11-15"
5
- }
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields": ["type"]
3
- }
@@ -1,74 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let DayRangeModel = require('../../../Models').DayRange(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('./dayRange.rules.json')
15
-
16
- let dayRange
17
-
18
- beforeEach(() => {
19
- dayRange = JSON.parse(JSON.stringify(require('./dayRange.data.json')))
20
- })
21
-
22
- testCase('DayRangeCondition', () => {
23
- testCase('Valid DayRangeCondition', () => {
24
- assertions('should validate a valid dayRange', (done) => {
25
- let DayRangeCondition = new DayRangeModel(dayRange)
26
- DayRangeCondition.validate((err, res) => {
27
- assert.notExists(res)
28
- assert(err === null, 'err should equals null')
29
- done()
30
- })
31
- })
32
- })
33
-
34
- testCase('Invalid DayRangeCondition', () => {
35
- assertions('should not validate a dayRange with invalid DayRangeCondition', (done) => {
36
- delete dayRange[rules.requiredFields[0]]
37
- let DayRangeCondition = new DayRangeModel(dayRange)
38
- DayRangeCondition.validate((err, res) => {
39
- assert.exists(err, 'err object should exist')
40
- assert.isObject(err)
41
- done()
42
- })
43
- })
44
-
45
- assertions('should throw an error if both startDate and endDate are not provided', (done) => {
46
- delete dayRange.startDate
47
- delete dayRange.endDate
48
- let DayRangeCondition = new DayRangeModel(dayRange)
49
- DayRangeCondition.validate((err, res) => {
50
- assert.exists(err, 'err object should exist')
51
- assert.isObject(err)
52
- done()
53
- })
54
- })
55
-
56
- testCase('check each required property of the model and validate that it is present', () => {
57
- let requiredFields = rules.requiredFields
58
- requiredFields.map((i) => {
59
- assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
60
- // delete i from geofeatures' dayRange child
61
- delete dayRange[i]
62
- let DayRangeCondition = new DayRangeModel(dayRange)
63
- DayRangeCondition.validate((err, res) => {
64
- assert.notExists(res)
65
- assert.exists(err, 'err object should exist')
66
- assert.isObject(err)
67
- assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
68
- done()
69
- })
70
- })
71
- })
72
- })
73
- })
74
- })
@@ -1,5 +0,0 @@
1
- {
2
- "type": "travelPath",
3
- "minimumGeofeaturesCrossed": 20,
4
- "timeOutSeconds": 300
5
- }
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields":["timeOutSeconds", "minimumGeofeaturesCrossed"]
3
- }
@@ -1,62 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let TravelPathConditionModel = require('../../../Models').TravelPath(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('./travelPath.rules.json')
15
-
16
- let travelPath
17
-
18
- beforeEach(() => {
19
- travelPath = JSON.parse(JSON.stringify(require('./travelPath.data.json')))
20
- })
21
-
22
- testCase('PercentageCrossedCondition', () => {
23
- testCase('Valid PercentageCrossedCondition', () => {
24
- assertions('should validate a valid travelPath ', (done) => {
25
- let PercentageCrossedCondition = new TravelPathConditionModel(travelPath)
26
- PercentageCrossedCondition.validate((err, res) => {
27
- assert.notExists(res)
28
- assert(err === null, 'err should equals null')
29
- done()
30
- })
31
- })
32
- })
33
-
34
- testCase('Invalid PercentageCrossedCondition', () => {
35
- assertions('should not validate a travelPath with invalid PercentageCrossedCondition', (done) => {
36
- delete travelPath[rules.requiredFields[0]]
37
- let PercentageCrossedCondition = new TravelPathConditionModel(travelPath)
38
- PercentageCrossedCondition.validate((err, res) => {
39
- assert.exists(err, 'err object should exist')
40
- assert.isObject(err)
41
- done()
42
- })
43
- })
44
- testCase('check each required property of the model and validate that it is present', () => {
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' travelPath child
49
- delete travelPath[i]
50
- let PercentageCrossedCondition = new TravelPathConditionModel(travelPath)
51
- PercentageCrossedCondition.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 ${i} property`)
56
- done()
57
- })
58
- })
59
- })
60
- })
61
- })
62
- })
@@ -1,5 +0,0 @@
1
- {
2
- "type" : "speed",
3
- "minimumSpeed" : 20,
4
- "maximumSpeed" : 26
5
- }
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields":["minimumSpeed", "maximumSpeed"]
3
- }
@@ -1,73 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let SpeedConditionModel = require('../../../Models').Speed(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('./speed.rules.json')
15
-
16
- let speedCondition
17
-
18
- beforeEach(() => {
19
- speedCondition = JSON.parse(JSON.stringify(require('./speed.data.json')))
20
- })
21
-
22
- testCase('SpeedCondition', () => {
23
- testCase('Valid SpeedCondition', () => {
24
- assertions('should validate a valid speedCondition ', (done) => {
25
- let SpeedCondition = new SpeedConditionModel(speedCondition)
26
- SpeedCondition.validate((err, res) => {
27
- assert.notExists(res)
28
- assert(err === null, 'err should equals null')
29
- done()
30
- })
31
- })
32
- })
33
-
34
- testCase('Invalid SpeedCondition', () => {
35
- assertions('should not validate a speedCondition with invalid SpeedCondition', (done) => {
36
- delete speedCondition[rules.requiredFields[0]]
37
- let SpeedCondition = new SpeedConditionModel(speedCondition)
38
- SpeedCondition.validate((err, res) => {
39
- assert.exists(err, 'err object should exist')
40
- assert.isObject(err)
41
- done()
42
- })
43
- })
44
- assertions('should throw an error when maxSpeed is less than 5 of minSpeed', (done) => {
45
- speedCondition.minimumSpeed = 10
46
- speedCondition.maximumSpeed = 11
47
- let SpeedCondition = new SpeedConditionModel(speedCondition)
48
- SpeedCondition.validate((err, res) => {
49
- assert.exists(err, 'err object should exist')
50
- assert.isObject(err)
51
- assert.nestedProperty(err, `errors.maximumSpeed`, 'error should have a maximumSpeed property')
52
- done()
53
- })
54
- })
55
- testCase('check each required property of the model and validate that it is present', () => {
56
- let requiredFields = rules.requiredFields
57
- requiredFields.map((i) => {
58
- assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
59
- // delete i from geofeatures' speedCondition child
60
- delete speedCondition[i]
61
- let SpeedCondition = new SpeedConditionModel(speedCondition)
62
- SpeedCondition.validate((err, res) => {
63
- assert.notExists(res)
64
- assert.exists(err, 'err object should exist')
65
- assert.isObject(err)
66
- assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
67
- done()
68
- })
69
- })
70
- })
71
- })
72
- })
73
- })
@@ -1,5 +0,0 @@
1
- {
2
- "type": "timeActiveCondition",
3
- "fromTime": "00:30:00",
4
- "toTime": "20:30:00"
5
- }
@@ -1,7 +0,0 @@
1
- {
2
- "requiredFields":["fromTime", "toTime"],
3
- "customValidators":[
4
- {"name": "fromTime", "invalidInput": [6800, "24:00:00", "invalid-input"]},
5
- {"name": "toTime", "invalidInput": [6800, "24:00:00", "invalid-input"]}
6
- ]
7
- }
@@ -1,94 +0,0 @@
1
- let mongoose = require('mongoose')
2
-
3
- mongoose.Promise = global.Promise
4
-
5
- let TimeActiveConditionModel = require('../../../Models').TimeActive(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 rules = require('./timeActive.rules.json')
14
-
15
- let timeActiveCondition
16
-
17
- beforeEach(() => {
18
- timeActiveCondition = JSON.parse(JSON.stringify(require('./timeActive.data.json')))
19
- })
20
-
21
- testCase('TimeOfDayRangeCondition', () => {
22
- testCase('Valid TimeOfDayRangeCondition', () => {
23
- assertions('should validate a valid timeActiveCondition ', (done) => {
24
- let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
25
- TimeOfDayRangeCondition.validate((err, res) => {
26
- assert.notExists(res)
27
- assert(err === null, 'err should equals null')
28
- done()
29
- })
30
- })
31
- })
32
-
33
- testCase('Invalid TimeOfDayRangeCondition', () => {
34
- assertions('should not validate a timeActiveCondition with invalid TimeOfDayRangeCondition', (done) => {
35
- delete timeActiveCondition[rules.requiredFields[0]]
36
- let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
37
- TimeOfDayRangeCondition.validate((err, res) => {
38
- assert.exists(err, 'err object should exist')
39
- assert.isObject(err)
40
- done()
41
- })
42
- })
43
- assertions('should throw an error when toTime === fromTime', (done) => {
44
- timeActiveCondition.toTime = "00:30:00"
45
- timeActiveCondition.fromTime = "00:30:00"
46
- let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
47
- TimeOfDayRangeCondition.validate((err, res) => {
48
- assert.exists(err, 'err object should exist')
49
- assert.isObject(err)
50
- assert.nestedProperty(err, `errors.toTime`, 'error should have a toTime property')
51
- done()
52
- })
53
- })
54
-
55
- testCase('recursive invalid time inputs check', () => {
56
- let invalidTimes = rules.customValidators
57
-
58
- invalidTimes.map(i => {
59
- i.invalidInput.map(j => {
60
- assertions(`should throw an error with property '${i.name}' if '${i.name} is invalid => ${i.name} = ${j}'`, done => {
61
- timeActiveCondition = JSON.parse(JSON.stringify(timeActiveCondition))
62
- timeActiveCondition[i.name] = j
63
- let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
64
- TimeOfDayRangeCondition.validate((err, res) => {
65
- assert.exists(err, 'err object should exits')
66
- assert.isObject(err)
67
- assert.nestedProperty(err, `errors.${i.name}`, 'time format must be hh:mm:ss')
68
- assert.nestedProperty(err, `errors.${i.name}`, 'time format must be hh:mm:ss')
69
- done()
70
- })
71
- })
72
- })
73
- })
74
- })
75
-
76
- testCase('check each required property of the model and validate that it is present', () => {
77
- let requiredFields = rules.requiredFields
78
- requiredFields.map((i) => {
79
- assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
80
- // delete i from geofeatures' timeActiveCondition child
81
- delete timeActiveCondition[i]
82
- let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
83
- TimeOfDayRangeCondition.validate((err, res) => {
84
- assert.notExists(res)
85
- assert.exists(err, 'err object should exist')
86
- assert.isObject(err)
87
- assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
88
- done()
89
- })
90
- })
91
- })
92
- })
93
- })
94
- })
@@ -1,5 +0,0 @@
1
- {
2
- "type" : "travelDirection",
3
- "fromAngle" : 0,
4
- "toAngle" : 90
5
- }
@@ -1,3 +0,0 @@
1
- {
2
- "requiredFields":["type", "fromAngle", "toAngle"]
3
- }