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

Commit bf843ff

Browse files
author
Kamil Kisiela
committed
test(inputContainer): check existance and inside wrapping
1 parent 92a7241 commit bf843ff

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

package.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Package.onTest(function(api) {
118118
'tests/client/test-utils.js',
119119
'tests/client/angular-material-mocks.js',
120120
'tests/client/formly-material-spec.js',
121+
// wrappers
122+
'tests/client/wrappers/input-container-spec.js',
121123
// types
122124
'tests/client/types/checkbox-spec.js',
123125
'tests/client/types/chips-spec.js',
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
describe("formlyMaterial - inputContainer wrapper", () => {
2+
3+
//
4+
// vars
5+
//
6+
let formlyConfig;
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
12+
//
13+
// helpers
14+
//
15+
16+
function compile() {
17+
$scope = $rootScope.$new();
18+
$scope.fields = [{
19+
key: 'testField',
20+
type: 'checkbox',
21+
wrapper: ['inputContainer'],
22+
templateOptions: {
23+
label: 'test field'
24+
}
25+
}];
26+
27+
let form = $compile(testUtils.formTemplate)($scope);
28+
$scope.$digest();
29+
element = form.find('md-input-container');
30+
}
31+
32+
//
33+
// tests
34+
//
35+
36+
beforeEach(() => {
37+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
38+
module('testApp');
39+
40+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
41+
$compile = _$compile_;
42+
$rootScope = _$rootScope_;
43+
formlyConfig = _formlyConfig_;
44+
});
45+
46+
const types = ['checkbox'];
47+
const wrappers = ['inputContainer'];
48+
49+
types.forEach((name) => {
50+
testUtils.fixTypeTemplateUrl(formlyConfig, name);
51+
});
52+
wrappers.forEach((name) => {
53+
testUtils.fixWrapperTemplateUrl(formlyConfig, name);
54+
});
55+
56+
compile();
57+
});
58+
59+
it('should exist', () => {
60+
expect(element.length).toBe(1);
61+
});
62+
63+
it("should contain field", () => {
64+
expect(element.find('md-checkbox').length).toBe(1);
65+
});
66+
67+
});

0 commit comments

Comments
 (0)