-
Notifications
You must be signed in to change notification settings - Fork 289
/
plugin_validation_service_tests.js
46 lines (35 loc) · 1.74 KB
/
plugin_validation_service_tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//dependencies
var util = require('util');
var should = require('should');
var TestHelpers = require('../../../../test_helpers.js');
describe('PluginValidationService', function() {
TestHelpers.registerReset();
describe('PluginValidationService.validateSettingValue', function() {
[1, 2.0, true, false, '', 'hello'].forEach(function(val) {
it('should return true when passed a value type of '+(typeof val), function() {
this.pb.PluginValidationService.validateSettingValue(val).should.eql(true);
});
});
});
describe('PluginValidationService.validateSetting', function() {
[1, 2.0, true, false, '', 'hello'].forEach(function(val) {
it('should callback with a validation error when not passed an object as the setting with value: '+(typeof val), function(done) {
var service = new this.pb.PluginValidationService();
service.validateSetting(val, {}, function(err, validationError) {
validationError.should.be.type('object');
done();
});
});
});
[1, 2.0, true, {}, []].forEach(function(val) {
it('should callback with a validation error when the group is provided and not a non-empty string: '+util.inspect(val), function(done) {
var service = new this.pb.PluginValidationService();
service.validateSetting({group: val, name: 'abc', value: '123'}, {index: 0}, function(err, validationErrors) {
validationErrors.length.should.eql(1);
validationErrors[0].field.should.eql('settings[0].group');
done();
});
});
});
});
});