Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit f2d2e40

Browse files
author
Kamil Kisiela
committed
test(chips): templateOptions.disabled
check attribute
1 parent e6104ea commit f2d2e40

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/types/chips-spec.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('formlyMaterial - chips type', () => {
1010
let $scope;
1111
let element;
1212
let field;
13+
let fieldScope;
1314

1415
function onAdd() {
1516
return true;
@@ -39,7 +40,8 @@ describe('formlyMaterial - chips type', () => {
3940
placeholder: '+tags',
4041
secondaryPlaceholder: 'Add tag',
4142
deleteButtonLabel: 'Remove',
42-
deleteHint: 'Remove tag'
43+
deleteHint: 'Remove tag',
44+
disabled: true
4345
}
4446
}, options)];
4547

@@ -48,6 +50,7 @@ describe('formlyMaterial - chips type', () => {
4850
$scope.$digest();
4951
field = $scope.fields[0];
5052
element = form.find('[ng-model]');
53+
fieldScope = angular.element(element).scope();
5154
}
5255

5356
//
@@ -86,23 +89,22 @@ describe('formlyMaterial - chips type', () => {
8689
});
8790

8891
it('should have onAdd callback', () => {
89-
const scope = angular.element(element).scope();
90-
9192
expect(element.attr('md-on-add')).toBe(`options.templateOptions['onAdd']`);
92-
expect(scope.options.templateOptions.onAdd).toBe(onAdd);
93+
expect(fieldScope.options.templateOptions.onAdd).toBe(onAdd);
9394
});
9495

9596
it('should have onRemove callback', () => {
96-
const scope = angular.element(element).scope();
97-
9897
expect(element.attr('md-on-remove')).toBe(`options.templateOptions['onRemove']`);
99-
expect(scope.options.templateOptions.onRemove).toBe(onRemove);
98+
expect(fieldScope.options.templateOptions.onRemove).toBe(onRemove);
10099
});
101100

102101
it('should have onSelect callback', () => {
103-
const scope = angular.element(element).scope();
104-
105102
expect(element.attr('md-on-select')).toBe(`options.templateOptions['onSelect']`);
106-
expect(scope.options.templateOptions.onSelect).toBe(onSelect);
103+
expect(fieldScope.options.templateOptions.onSelect).toBe(onSelect);
104+
});
105+
106+
it('should be disabled and have readonly attribute', () => {
107+
expect(element[0].attributes.readonly.value).toBe('to.disabled');
108+
expect(fieldScope.options.templateOptions.disabled).toBe(true);
107109
});
108110
});

0 commit comments

Comments
 (0)