@bluedot-innovation/models 5.1.26 → 5.1.27-alpha.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/CHANGELOG.md +3 -0
- package/__tests__/beacon/beacon.spec.js +29 -0
- package/helpers.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -138,5 +138,34 @@ describe('Beacon', () => {
|
|
|
138
138
|
})
|
|
139
139
|
})
|
|
140
140
|
})
|
|
141
|
+
|
|
142
|
+
describe('should fail validation when passed an invalid Mac Address', () => {
|
|
143
|
+
const beaconTypes = ['Android', 'Both'];
|
|
144
|
+
const invalidMacAddresses = [
|
|
145
|
+
'invalid mac address',
|
|
146
|
+
1324,
|
|
147
|
+
false,
|
|
148
|
+
undefined,
|
|
149
|
+
'F:9:0:4:F:2',
|
|
150
|
+
'F:90:0B:4E:F0:22',
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
beaconTypes.forEach(beaconType => {
|
|
154
|
+
invalidMacAddresses.forEach(value => {
|
|
155
|
+
it(`should throw an error with a Mac Address with value: ${value} and beaconType: ${beaconType}`, (done) => {
|
|
156
|
+
let Beacon = new BeaconModel(beacon);
|
|
157
|
+
Beacon.beaconType = beaconType;
|
|
158
|
+
Beacon.macAddress = value
|
|
159
|
+
Beacon.validate((err, res) => {
|
|
160
|
+
assert.notExists(res)
|
|
161
|
+
assert.exists(err, 'err object should exist')
|
|
162
|
+
assert.isObject(err)
|
|
163
|
+
assert.nestedProperty(err, 'errors.macAddress' ,`error should have a macAddress property`)
|
|
164
|
+
done()
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
})
|
|
141
170
|
})
|
|
142
171
|
})
|
package/helpers.js
CHANGED
|
@@ -168,7 +168,7 @@ helpers.validateNotNull = function(value) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
helpers.isValidMacAddress = function (value){
|
|
171
|
-
return /^([0-9a-f]{
|
|
171
|
+
return /^([0-9a-f]{2}[\:]){5}([0-9a-f]{2})$/i.test(value);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
const isValidObject = data => {
|
package/package.json
CHANGED