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

Commit 92a7241

Browse files
author
Kamil Kisiela
committed
test(textarea): check existance of wrappers and support for rows and cols
1 parent ea1e13b commit 92a7241

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

package.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Package.onTest(function(api) {
126126
'tests/client/types/radio-spec.js',
127127
'tests/client/types/select-spec.js',
128128
'tests/client/types/slider-spec.js',
129-
'tests/client/types/switch-spec.js'
129+
'tests/client/types/switch-spec.js',
130+
'tests/client/types/textarea-spec.js'
130131
], client);
131132
});

tests/client/types/textarea-spec.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
describe("formlyMaterial - textarea type", () => {
2+
3+
//
4+
// vars
5+
//
6+
7+
let formlyConfig;
8+
let $compile;
9+
let $rootScope;
10+
let $scope;
11+
let form;
12+
let element;
13+
let field;
14+
15+
//
16+
// helpers
17+
//
18+
19+
function compile(options) {
20+
$scope = $rootScope.$new();
21+
$scope.fields = [angular.merge({}, {
22+
key: 'testField',
23+
type: 'textarea',
24+
templateOptions: {
25+
label: 'test field',
26+
rows: 5,
27+
cols: 6
28+
}
29+
}, options)];
30+
31+
form = $compile(testUtils.formTemplate)($scope);
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 = ['textarea'];
52+
const wrappers = ['messages', 'label', 'inputContainer'];
53+
54+
types.forEach((type) => {
55+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
56+
});
57+
wrappers.forEach((wrapper) => {
58+
testUtils.fixWrapperTemplateUrl(formlyConfig, wrapper);
59+
});
60+
61+
compile();
62+
});
63+
64+
it('should be input element', () => {
65+
expect(element[0].nodeName).toBe('TEXTAREA');
66+
});
67+
68+
it('should have messages wrapper', () => {
69+
expect(form.find('[ng-messages]').length).toBe(1);
70+
});
71+
72+
it('should have label wrapper', () => {
73+
let label = form.find('label');
74+
75+
expect(label.length).toBe(1);
76+
expect(label[0].innerText).toContain(field.templateOptions.label);
77+
});
78+
79+
it('should have inputContainer wrapper', () => {
80+
expect(form.find('md-input-container').length).toBe(1);
81+
});
82+
83+
it('should be able to set rows', () => {
84+
expect(parseInt(element.attr('rows'))).toEqual(field.templateOptions.rows);
85+
});
86+
87+
it('should be able to set cols', () => {
88+
expect(parseInt(element.attr('cols'))).toEqual(field.templateOptions.cols);
89+
});
90+
91+
});

0 commit comments

Comments
 (0)