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

Commit 8bacd6c

Browse files
author
Kamil Kisiela
committed
test(checkbox): add missing tests
1 parent 9c1125a commit 8bacd6c

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

package.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Package.onTest(function(api) {
116116

117117
api.addFiles([
118118
'tests/client/test-utils.js',
119-
'tests/client/formly-material-spec.js'
119+
'tests/client/formly-material-spec.js',
120+
// types
121+
'tests/client/types/checkbox-spec.js'
120122
], client);
121123
});

tests/client/types/checkbox-spec.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
describe("formlyMaterial - checkbox type", () => {
2+
3+
//
4+
// vars
5+
//
6+
let formlyConfig;
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
//
12+
// helpers
13+
//
14+
15+
function compile(options) {
16+
$scope = $rootScope.$new();
17+
$scope.fields = [angular.merge({}, {
18+
key: 'testField',
19+
type: 'checkbox',
20+
templateOptions: {
21+
label: 'test field'
22+
}
23+
}, options)];
24+
25+
let form = $compile(testUtils.formTemplate)($scope);
26+
$scope.$digest();
27+
element = form.find('[ng-model]')[0];
28+
}
29+
30+
//
31+
// tests
32+
//
33+
34+
beforeEach(() => {
35+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
36+
module('testApp');
37+
38+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
39+
$compile = _$compile_;
40+
$rootScope = _$rootScope_;
41+
formlyConfig = _formlyConfig_;
42+
});
43+
44+
const types = ['checkbox'];
45+
46+
types.forEach((type) => {
47+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
48+
});
49+
50+
compile();
51+
});
52+
53+
it('should be md-checkbox element', () => {
54+
expect(element.nodeName).toBe('MD-CHECKBOX');
55+
});
56+
57+
it("should have label", () => {
58+
console.log(angular.element(element));
59+
expect(element.innerText).toContain("test field");
60+
});
61+
62+
});

0 commit comments

Comments
 (0)