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

Commit 2ca386c

Browse files
author
Kamil Kisiela
committed
test(chips): check this templateOptions: placeholder, secondaryPlaceholder, deleteButtonLabel, deleteHint
1 parent 9fab17a commit 2ca386c

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

package.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Package.onTest(function(api) {
118118
'tests/client/test-utils.js',
119119
'tests/client/formly-material-spec.js',
120120
// types
121-
'tests/client/types/checkbox-spec.js'
121+
'tests/client/types/checkbox-spec.js',
122+
'tests/client/types/chips-spec.js'
122123
], client);
123124
});

tests/client/types/chips-spec.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
describe("formlyMaterial - chips type", () => {
2+
3+
//
4+
// vars
5+
//
6+
let formlyConfig;
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
let field;
12+
//
13+
// helpers
14+
//
15+
16+
function compile(options) {
17+
$scope = $rootScope.$new();
18+
$scope.fields = [angular.merge({}, {
19+
key: 'testField',
20+
type: 'chips',
21+
templateOptions: {
22+
label: 'test field',
23+
placeholder: "+tags",
24+
secondaryPlaceholder: "Add tag",
25+
deleteButtonLabel: "Remove",
26+
deleteHint: "Remove tag"
27+
}
28+
}, options)];
29+
30+
let form = $compile(testUtils.formTemplate)($scope);
31+
32+
$scope.$digest();
33+
field = $scope.fields[0];
34+
element = form.find('[ng-model]');
35+
}
36+
37+
//
38+
// tests
39+
//
40+
41+
beforeEach(() => {
42+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
43+
module('testApp');
44+
45+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
46+
$compile = _$compile_;
47+
$rootScope = _$rootScope_;
48+
formlyConfig = _formlyConfig_;
49+
});
50+
51+
const types = ['chips'];
52+
53+
types.forEach((type) => {
54+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
55+
});
56+
57+
compile();
58+
});
59+
60+
it('should be md-chips element', () => {
61+
expect(element[0].nodeName).toBe('MD-CHIPS');
62+
});
63+
64+
it('should have placeholder', () => {
65+
expect(element.attr('placeholder')).toBe(field.templateOptions.placeholder);
66+
});
67+
68+
it('should have secondary placeholder', () => {
69+
expect(element.attr('secondary-placeholder')).toBe(field.templateOptions.secondaryPlaceholder);
70+
});
71+
72+
it('should have delete button label', () => {
73+
expect(element.attr('delete-button-label')).toBe(field.templateOptions.deleteButtonLabel);
74+
});
75+
76+
it('should have delete hint', () => {
77+
expect(element.attr('delete-hint')).toBe(field.templateOptions.deleteHint);
78+
});
79+
80+
});

0 commit comments

Comments
 (0)