Rendering array field
Change-Id: Iceae98b69e6add7e8e89b05cb66e015bfcc845b4
diff --git a/spec/ui/field.test.js b/spec/ui/field.test.js
index 2d7d389..6260ac8 100644
--- a/spec/ui/field.test.js
+++ b/spec/ui/field.test.js
@@ -273,6 +273,49 @@
});
});
+ describe('when an array input is passed', () => {
+ beforeEach(() => {
+ scope = rootScope.$new();
+ scope.name = 'label';
+ scope.field = {
+ label: 'Label',
+ type: 'array',
+ validators: {},
+ options: ['1', '2', '3', '4', '5']
+ };
+ scope.ngModel = ['1', '2', '3'];
+ compileElement();
+ });
+
+ it('should print a panel to contain array values', () => {
+ expect($(element).find('.panel.array-field')).toExist()
+ });
+
+ it('should print selected values', () => {
+ expect($(element).find('.panel.array-field .selected .array-element')).toHaveLength(3)
+ });
+
+ it('should print un-selected values', () => {
+ expect($(element).find('.panel.array-field .unselected .array-element')).toHaveLength(2)
+ });
+
+ describe('when a value is added', () => {
+ it('should be removed from unselected', () => {
+ isolatedScope.ngModel.push('4');
+ scope.$apply();
+ expect($(element).find('.panel.array-field .unselected .array-element')).toHaveLength(1)
+ });
+ });
+
+ describe('when a value is removed', () => {
+ it('should be added to unselected', () => {
+ isolatedScope.ngModel.pop();
+ scope.$apply();
+ expect($(element).find('.panel.array-field .unselected .array-element')).toHaveLength(3)
+ });
+ });
+ });
+
describe('when validation options are passed', () => {
let input;
describe('given a a text field', () => {
diff --git a/spec/ui/form.test.js b/spec/ui/form.test.js
index e92d31a..2fe27bc 100644
--- a/spec/ui/form.test.js
+++ b/spec/ui/form.test.js
@@ -102,10 +102,10 @@
});
it('should render 10 input field', () => {
- // boolean are in the form model, but are not input
+ // boolean and arrays are in the form model, but are not input
expect(Object.keys(isolatedScope.formField).length).toEqual(9);
const field = element[0].getElementsByTagName('input');
- expect(field.length).toEqual(10);
+ expect(field.length).toEqual(9);
});
it('should render 1 boolean field', () => {