Added custom validation option to xosField component
diff --git a/views/ngXosLib/xosHelpers/spec/ui/field.test.js b/views/ngXosLib/xosHelpers/spec/ui/field.test.js
index 8b32585..8a02d4d 100644
--- a/views/ngXosLib/xosHelpers/spec/ui/field.test.js
+++ b/views/ngXosLib/xosHelpers/spec/ui/field.test.js
@@ -7,24 +7,23 @@
(function () {
'use strict';
- let element, scope, isolatedScope, rootScope, compile;
- const compileElement = (el) => {
- element = el;
-
- if(!scope){
- scope = rootScope.$new();
- }
- if(angular.isUndefined(element)){
- element = angular.element('<xos-field name="name" field="field" ng-model="ngModel"></xos-field>');
- }
- compile(element)(scope);
- scope.$digest();
- isolatedScope = element.isolateScope().vm;
- };
-
describe('The xos.helper module', function(){
describe('The xosField component', () => {
+ let element, scope, isolatedScope, rootScope, compile;
+ const compileElement = (el) => {
+ element = el;
+
+ if(!scope){
+ scope = rootScope.$new();
+ }
+ if(angular.isUndefined(element)){
+ element = angular.element('<xos-field name="name" field="field" ng-model="ngModel"></xos-field>');
+ }
+ compile(element)(scope);
+ scope.$digest();
+ isolatedScope = element.isolateScope().vm;
+ };
beforeEach(module('xos.helpers'));
@@ -93,7 +92,9 @@
scope.field = {
label: 'Label',
type: 'text',
- validators: {}
+ validators: {
+ custom: 'fake'
+ }
};
scope.ngModel = 'label';
compileElement();
@@ -102,6 +103,12 @@
it('should print a text field', () => {
expect($(element).find('[name="label"]')).toHaveAttr('type', 'text');
});
+
+ it('should attach the custom validator directive', () => {
+ let input = $(element).find('[name="label"]');
+ expect(input).toHaveAttr('xos-custom-validator');
+ expect(input).toHaveAttr('custom-validator', 'vm.field.validators.custom || null');
+ });
});
describe('when a option is selected in dropdown', () => {
@@ -266,7 +273,6 @@
});
});
- // NOTE not sure why this tests are failing
describe('when validation options are passed', () => {
let input;
describe('given a a text field', () => {