upgrade to angular 1.5.9
Change-Id: If3dda42818a2eb86f240f826bd67ba2f6e6741c4
diff --git a/bower.json b/bower.json
index 3b6b6b3..42df708 100644
--- a/bower.json
+++ b/bower.json
@@ -15,24 +15,24 @@
"./bower_components"
],
"dependencies": {
- "angular": "1.4.7",
+ "angular": "~1.5.9",
"angular-ui-router": "0.2.15",
- "angular-resource": "1.4.7",
- "angular-cookies": "1.4.7",
- "angular-animate": "1.4.7",
+ "angular-resource": "~1.5.9",
+ "angular-cookies": "~1.5.9",
+ "angular-animate": "~1.5.9",
"lodash": "~4.11.1",
"angular-chart.js": "~0.10.2",
"d3": "~3.5.17",
"angular-recursion": "~1.0.5"
},
"devDependencies": {
- "angular-mocks": "1.4.7",
+ "angular-mocks": "~1.5.9",
"jasmine-jquery": "~2.1.1",
"jquery": "~3.0.0",
"bootstrap-sass": "~3.3.6"
},
"resolutions": {
- "angular": "1.4.7"
+ "angular": "~1.5.9"
},
"main": [
"./dist/xosUiComponent.js"
diff --git a/karma.conf.js b/karma.conf.js
index 76d232c..3d07ec2 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -7,7 +7,7 @@
/* eslint indent: [2,2], quotes: [2, "single"]*/
// this is to load a different suite of test while developing
- const testFiles = '*';
+ let testFiles = '*';
if(process.argv[4]){
testFiles = process.argv[4];
}
diff --git a/package.json b/package.json
index f123fad..a59265a 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"lint:src": "eslint src/",
"lint:spec": "eslint spec/",
"lint": "npm run lint:src && npm run lint:spec",
- "postinstall": "cd node_modules/gulp-ngdocs/; npm install"
+ "postinstall": "cd node_modules/gulp-ngdocs/ && npm install"
},
"author": "Open Networking Laboratory",
"license": "Apache 2.0",
diff --git a/spec/ui/field.test.js b/spec/ui/field.test.js
index bfb36a3..2d7d389 100644
--- a/spec/ui/field.test.js
+++ b/spec/ui/field.test.js
@@ -1,330 +1,333 @@
-/**
- * © OpenCORD
- *
- * Created by teone on 5/25/16.
- */
-
-(function () {
- 'use strict';
-
- 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'));
-
- beforeEach(inject(function ($compile, $rootScope) {
- compile = $compile;
- rootScope = $rootScope;
- }));
-
- it('should throw an error if no name is passed', inject(($compile, $rootScope) => {
- function errorFunctionWrapper(){
- // setup the parent scope
- scope = $rootScope.$new();
- scope.field = {
- label: 'Label',
- type: 'number',
- validators: {}
- };
- scope.ngModel = 1;
- compileElement();
- }
- expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a field name'));
- }));
-
- it('should throw an error if no field definition is passed', inject(($compile, $rootScope) => {
- function errorFunctionWrapper(){
- // setup the parent scope
- scope = $rootScope.$new();
- scope.name = 'label';
- scope.ngModel = 1;
- compileElement();
- }
- expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a field definition'));
- }));
-
- it('should throw an error if no field type is passed', inject(($compile, $rootScope) => {
- function errorFunctionWrapper(){
- // setup the parent scope
- scope = $rootScope.$new();
- scope.name = 'label';
- scope.ngModel = 1;
- scope.field = {label: 'Label:'}
- compileElement();
- }
- expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a type in the field definition'));
- }));
-
- it('should throw an error if no field model is passed', inject(($compile, $rootScope) => {
- function errorFunctionWrapper(){
- // setup the parent scope
- scope = $rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'number',
- validators: {}
- };
- compileElement(angular.element('<xos-field name="name" field="field"></xos-field>'));
- }
- expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide an ng-model'));
- }));
-
- describe('when a text input is passed', () => {
- beforeEach(() => {
- scope = rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'text',
- validators: {
- custom: 'fake'
- }
- };
- scope.ngModel = 'label';
- compileElement();
- });
-
- 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', () => {
- beforeEach(() => {
- scope = rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'select',
- validators: {},
- options: [
- {
- id: 0,
- label: '---Site---'
- },
- {
- id: 1,
- label: '---Site1---'
- }
- ]
- };
- scope.ngModel = 0;
- compileElement();
- });
-
- it('No of select elements', () => {
- expect($(element).find('select').children('option').length).toEqual(2);
- });
-
- it('should show the selected value', () => {
- const elem = angular.element($(element).find('select').children('option')[0]);
- expect(elem.text()).toEqual('---Site---');
- expect(elem).toHaveAttr('selected');
- });
- });
-
- describe('when a number input is passed', () => {
- beforeEach(() => {
- scope = rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'number',
- validators: {}
- };
- scope.ngModel = 10;
- compileElement();
- });
-
- it('should print a number field', () => {
- expect($(element).find('[name="label"]')).toHaveAttr('type', 'number');
- });
- });
-
- describe('when a boolean input is passed', () => {
- beforeEach(() => {
- scope = rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'boolean',
- validators: {}
- };
- scope.ngModel = true;
- compileElement();
- });
-
- let setFalse, setTrue;
-
- beforeEach(() => {
- setFalse= $(element).find('.boolean-field > a:first-child');
- setTrue = $(element).find('.boolean-field > a:last-child');
- });
-
- it('should print two buttons', () => {
- expect($(element).find('.boolean-field > a').length).toEqual(2)
- });
-
- it('should change value to false', () => {
- expect(isolatedScope.ngModel).toEqual(true);
- clickElement(setFalse[0]);
- expect(isolatedScope.ngModel).toEqual(false);
- });
-
- it('should change value to true', () => {
- isolatedScope.ngModel = false;
- scope.$apply();
- expect(isolatedScope.ngModel).toEqual(false);
- clickElement(setTrue[0]);
- expect(isolatedScope.ngModel).toEqual(true);
- });
- });
-
- describe('when an object input is passed', () => {
- beforeEach(() => {
- scope = rootScope.$new();
- scope.name = 'label';
- scope.field = {
- label: 'Label',
- type: 'object',
- validators: {}
- };
- scope.ngModel = {
- baz: true,
- foo: 'bar',
- foz: 1,
- };
- compileElement();
- });
-
- it('should print a panel to contain object property field', () => {
- expect($(element).find('.panel.object-field')).toExist()
- });
-
- it('should print the right input type for each property', () => {
- expect($(element).find('input').length).toBe(2);
- expect($(element).find('.boolean-field > a').length).toEqual(2);
- });
-
- it('should format labels', () => {
- expect($(element).find('input[name="foo"]').parent().find('label').text()).toBe('Foo:');
- });
-
- describe('and the model is empty', () => {
- beforeEach(() => {
- scope.ngModel = {
- };
- compileElement();
- });
-
- it('should not print the panel', () => {
- expect($(element).find('.panel.object-field')).not.toExist()
- });
-
- describe('but field is configured', () => {
- beforeEach(() => {
- scope.field.properties = {
- foo: {
- label: 'FooLabel:',
- type: 'string',
- validators: {
- required: true
- }
- },
- bar: {
- type: 'number'
- }
- };
- compileElement();
- });
- it('should render panel and configured fields', () => {
- expect($(element).find('.panel.object-field')).toExist();
- expect($(element).find('input[name="foo"]').parent().find('label').text()).toBe('FooLabel:');
- expect($(element).find('input[name="foo"]')).toHaveAttr('type', 'string');
- expect($(element).find('input[name="foo"]')).toHaveAttr('required');
-
- expect($(element).find('input[name="bar"]').parent().find('label').text()).toBe('Bar:');
- expect($(element).find('input[name="bar"]')).toHaveAttr('type', 'number');
-
- });
- });
- });
- });
-
- describe('when validation options are passed', () => {
- let input;
- describe('given a a text field', () => {
- beforeEach(() => {
- scope.field = {
- label: 'Label',
- type: 'text',
- validators: {
- minlength: 10,
- maxlength: 15,
- required: true
- }
- };
-
- scope.$digest();
- input = $(element).find('input');
- });
-
- it('should validate required', () => {
- scope.ngModel= null;
- scope.$digest();
- expect(input).toHaveClass('ng-invalid-required');
-
- scope.ngModel= 'not too short';
- scope.$digest();
- expect(input).not.toHaveClass('ng-invalid-required');
- expect(input).not.toHaveClass('ng-invalid');
- });
-
- it('should validate minlength', () => {
- scope.ngModel= 'short';
- scope.$digest();
- expect(input).toHaveClass('ng-invalid-minlength');
-
- scope.ngModel= 'not too short';
- scope.$digest();
- expect(input).not.toHaveClass('ng-invalid-minlength');
- expect(input).not.toHaveClass('ng-invalid');
- });
-
- it('should validate maxlength', () => {
- scope.ngModel= 'this is definitely too long!!';
- scope.$digest();
- expect(input).toHaveClass('ng-invalid-maxlength');
-
- scope.ngModel= 'not too short';
- scope.$digest();
- expect(input).not.toHaveClass('ng-invalid-maxlength');
- expect(input).not.toHaveClass('ng-invalid');
- });
- });
- });
- });
- });
+/**
+ * © OpenCORD
+ *
+ * Created by teone on 5/25/16.
+ */
+
+(function () {
+ 'use strict';
+
+ 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'));
+
+ beforeEach(inject(function ($compile, $rootScope) {
+ compile = $compile;
+ rootScope = $rootScope;
+ }));
+
+ it('should throw an error if no name is passed', inject(($compile, $rootScope) => {
+ function errorFunctionWrapper(){
+ // setup the parent scope
+ scope = $rootScope.$new();
+ scope.field = {
+ label: 'Label',
+ type: 'number',
+ validators: {}
+ };
+ scope.ngModel = 1;
+ compileElement();
+ }
+ expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a field name'));
+ }));
+
+ it('should throw an error if no field definition is passed', inject(($compile, $rootScope) => {
+ function errorFunctionWrapper(){
+ // setup the parent scope
+ scope = $rootScope.$new();
+ scope.name = 'label';
+ scope.ngModel = 1;
+ compileElement();
+ }
+ expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a field definition'));
+ }));
+
+ it('should throw an error if no field type is passed', inject(($compile, $rootScope) => {
+ function errorFunctionWrapper(){
+ // setup the parent scope
+ scope = $rootScope.$new();
+ scope.name = 'label';
+ scope.ngModel = 1;
+ scope.field = {label: 'Label:'}
+ compileElement();
+ }
+ expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide a type in the field definition'));
+ }));
+
+ it('should throw an error if no field model is passed', inject(($compile, $rootScope) => {
+ function errorFunctionWrapper(){
+ // setup the parent scope
+ scope = $rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'number',
+ validators: {}
+ };
+ compileElement(angular.element('<xos-field name="name" field="field"></xos-field>'));
+ }
+ expect(errorFunctionWrapper).toThrow(new Error('[xosField] Please provide an ng-model'));
+ }));
+
+ describe('when a text input is passed', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'text',
+ validators: {
+ custom: 'fake'
+ }
+ };
+ scope.ngModel = 'label';
+ compileElement();
+ });
+
+ 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', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'select',
+ validators: {},
+ options: [
+ {
+ id: 0,
+ label: '---Site---'
+ },
+ {
+ id: 1,
+ label: '---Site1---'
+ }
+ ]
+ };
+ scope.ngModel = 0;
+ compileElement();
+ });
+
+ it('No of select elements', () => {
+ expect($(element).find('select').children('option').length).toEqual(2);
+ });
+
+ it('should show the selected value', () => {
+ const elem = angular.element($(element).find('select').children('option')[0]);
+ expect(elem.text()).toEqual('---Site---');
+ expect(elem).toHaveAttr('selected');
+ });
+ });
+
+ describe('when a number input is passed', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'number',
+ validators: {}
+ };
+ scope.ngModel = 10;
+ compileElement();
+ });
+
+ it('should print a number field', () => {
+ expect($(element).find('[name="label"]')).toHaveAttr('type', 'number');
+ });
+ });
+
+ describe('when a boolean input is passed', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'boolean',
+ validators: {}
+ };
+ scope.ngModel = true;
+ compileElement();
+ });
+
+ let setFalse, setTrue;
+
+ beforeEach(() => {
+ setFalse= $(element).find('.boolean-field > a:first-child');
+ setTrue = $(element).find('.boolean-field > a:last-child');
+ });
+
+ it('should print two buttons', () => {
+ expect($(element).find('.boolean-field > a').length).toEqual(2)
+ });
+
+ it('should change value to false', () => {
+ expect(isolatedScope.ngModel).toEqual(true);
+ clickElement(setFalse[0]);
+ expect(isolatedScope.ngModel).toEqual(false);
+ });
+
+ it('should change value to true', () => {
+ isolatedScope.ngModel = false;
+ scope.$apply();
+ expect(isolatedScope.ngModel).toEqual(false);
+ clickElement(setTrue[0]);
+ expect(isolatedScope.ngModel).toEqual(true);
+ });
+ });
+
+ describe('when an object input is passed', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'object',
+ validators: {}
+ };
+ scope.ngModel = {
+ baz: true,
+ foo: 'bar',
+ foz: 1,
+ };
+ compileElement();
+ });
+
+ it('should print a panel to contain object property field', () => {
+ expect($(element).find('.panel.object-field')).toExist()
+ });
+
+ it('should print the right input type for each property', () => {
+ expect($(element).find('input').length).toBe(2);
+ expect($(element).find('.boolean-field > a').length).toEqual(2);
+ });
+
+ it('should format labels', () => {
+ expect($(element).find('input[name="foo"]').parent().find('label').text()).toBe('Foo:');
+ });
+
+ describe('and the model is empty', () => {
+ beforeEach(() => {
+ scope.ngModel = {
+ };
+ compileElement();
+ });
+
+ it('should not print the panel', () => {
+ expect($(element).find('.panel.object-field')).not.toExist()
+ });
+
+ describe('but field is configured', () => {
+ beforeEach(() => {
+ scope.field.properties = {
+ foo: {
+ label: 'FooLabel:',
+ type: 'string',
+ validators: {
+ required: true
+ }
+ },
+ bar: {
+ type: 'number'
+ }
+ };
+ compileElement();
+ });
+ it('should render panel and configured fields', () => {
+ expect($(element).find('.panel.object-field')).toExist();
+ expect($(element).find('input[name="foo"]').parent().find('label').text()).toBe('FooLabel:');
+ expect($(element).find('input[name="foo"]')).toHaveAttr('type', 'string');
+ expect($(element).find('input[name="foo"]')).toHaveAttr('required');
+
+ expect($(element).find('input[name="bar"]').parent().find('label').text()).toBe('Bar:');
+ expect($(element).find('input[name="bar"]')).toHaveAttr('type', 'number');
+
+ });
+ });
+ });
+ });
+
+ describe('when validation options are passed', () => {
+ let input;
+ describe('given a a text field', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name='label';
+ scope.field = {
+ label: 'Label',
+ type: 'text',
+ validators: {
+ minlength: 10,
+ maxlength: 15,
+ required: true
+ }
+ };
+
+ compileElement();
+ scope.$digest();
+ input = $(element).find('input');
+ });
+
+ it('should validate required', () => {
+ scope.ngModel= null;
+ scope.$digest();
+ expect(input).toHaveClass('ng-invalid-required');
+
+ scope.ngModel= 'not too short';
+ scope.$digest();
+ expect(input).not.toHaveClass('ng-invalid-required');
+ expect(input).not.toHaveClass('ng-invalid');
+ });
+
+ it('should validate minlength', () => {
+ scope.ngModel= 'short';
+ scope.$digest();
+ expect(input).toHaveClass('ng-invalid-minlength');
+
+ scope.ngModel= 'not too short';
+ scope.$digest();
+ expect(input).not.toHaveClass('ng-invalid-minlength');
+ expect(input).not.toHaveClass('ng-invalid');
+ });
+
+ it('should validate maxlength', () => {
+ scope.ngModel= 'this is definitely too long!!';
+ scope.$digest();
+ expect(input).toHaveClass('ng-invalid-maxlength');
+
+ scope.ngModel= 'not too short';
+ scope.$digest();
+ expect(input).not.toHaveClass('ng-invalid-maxlength');
+ expect(input).not.toHaveClass('ng-invalid');
+ });
+ });
+ });
+ });
+ });
})();
\ No newline at end of file