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

Commit daf0ae6

Browse files
author
Kamil Kisiela
committed
test(templateOptions.theme): basic tests
1 parent 6c7be7a commit daf0ae6

File tree

2 files changed

+64
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)