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

Commit c20a46d

Browse files
author
Kamil Kisiela
committed
test(textarea): grow option
1 parent 22a9458 commit c20a46d

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

tests/runs/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
import './md-theme-manipulator-spec';
1+
import './md-theme-manipulator-spec';
2+
import './md-no-autogrow-spec';

tests/runs/md-no-autogrow-spec.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import testUtils from './../test-utils';
2+
3+
describe("formlyMaterial - textarea no autogrow manipulator", () => {
4+
5+
//
6+
// vars
7+
//
8+
let formlyConfig;
9+
let $compile;
10+
let $rootScope;
11+
let $scope;
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+
grow: false
27+
}
28+
}, options)];
29+
30+
let form = $compile(testUtils.getFormTemplate())($scope);
31+
32+
$scope.$digest();
33+
element = form.find('[ng-model]');
34+
field = $scope.fields[0];
35+
}
36+
37+
//
38+
// tests
39+
//
40+
41+
beforeEach(() => {
42+
window.module('formlyMaterial');
43+
44+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
45+
$compile = _$compile_;
46+
$rootScope = _$rootScope_;
47+
formlyConfig = _formlyConfig_;
48+
});
49+
50+
compile();
51+
});
52+
53+
it('should be able to add md-no-autogrow attribute when grow equals false', () => {
54+
compile();
55+
expect(element.attr('md-no-autogrow')).toBeDefined();
56+
});
57+
58+
it("should be able to skip md-no-autogrow", () => {
59+
compile({
60+
extras: {
61+
skipNgModelAttrsManipulator: true
62+
}
63+
});
64+
expect(element.attr('md-no-autogrow')).toBeUndefined();
65+
});
66+
67+
});

0 commit comments

Comments
 (0)