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

Commit ea1e13b

Browse files
author
Kamil Kisiela
committed
test(switch): support for label
1 parent 6bec26e commit ea1e13b

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

package.js

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

tests/client/types/switch-spec.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
describe("formlyMaterial - switch type", () => {
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(options) {
17+
$scope = $rootScope.$new();
18+
$scope.fields = [angular.merge({}, {
19+
key: 'testField',
20+
type: 'switch',
21+
templateOptions: {
22+
label: 'test field'
23+
}
24+
}, options)];
25+
26+
let form = $compile(testUtils.formTemplate)($scope);
27+
$scope.$digest();
28+
element = form.find('[ng-model]');
29+
field = $scope.fields[0];
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 = ['switch'];
47+
48+
types.forEach((type) => {
49+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
50+
});
51+
52+
compile();
53+
});
54+
55+
it('should be md-switch element', () => {
56+
expect(element[0].nodeName).toBe('MD-SWITCH');
57+
});
58+
59+
it("should have label", () => {
60+
expect(element.find('.md-label > span')[0].innerText).toContain(field.templateOptions.label);
61+
});
62+
63+
});

0 commit comments

Comments
 (0)