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

Commit 901fbd0

Browse files
author
Kamil Kisiela
committed
test(datepicker): check existance of wrappers and templateOptions
1 parent 2ca386c commit 901fbd0

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

package.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Package.onTest(function(api) {
119119
'tests/client/formly-material-spec.js',
120120
// types
121121
'tests/client/types/checkbox-spec.js',
122-
'tests/client/types/chips-spec.js'
122+
'tests/client/types/chips-spec.js',
123+
'tests/client/types/datepicker-spec.js'
123124
], client);
124125
});

tests/client/types/datepicker-spec.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
describe("formlyMaterial - datepicker type", () => {
2+
3+
//
4+
// vars
5+
//
6+
let formlyConfig;
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let form;
11+
let element;
12+
let field;
13+
//
14+
// helpers
15+
//
16+
17+
function compile(options) {
18+
$scope = $rootScope.$new();
19+
$scope.fields = [angular.merge({}, {
20+
key: 'testField',
21+
type: 'datepicker',
22+
templateOptions: {
23+
label: 'test field',
24+
placeholder: "Pick a date",
25+
minDate: new Date(2015, 11, 19),
26+
maxDate: new Date(2015, 12, 20),
27+
filterDate: (date) => {
28+
return true;
29+
}
30+
}
31+
}, options)];
32+
33+
form = $compile(testUtils.formTemplate)($scope);
34+
$scope.$digest();
35+
field = $scope.fields[0];
36+
element = form.find('[ng-model]');
37+
}
38+
39+
//
40+
// tests
41+
//
42+
43+
beforeEach(() => {
44+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
45+
module('testApp');
46+
47+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
48+
$compile = _$compile_;
49+
$rootScope = _$rootScope_;
50+
formlyConfig = _formlyConfig_;
51+
});
52+
53+
const types = ['datepicker'];
54+
const wrappers = ['messages'];
55+
56+
types.forEach((type) => {
57+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
58+
});
59+
wrappers.forEach((wrapper) => {
60+
testUtils.fixWrapperTemplateUrl(formlyConfig, wrapper);
61+
});
62+
63+
compile();
64+
});
65+
66+
it('should be md-chips element', () => {
67+
expect(element[0].nodeName).toBe('MD-DATEPICKER');
68+
});
69+
70+
it('should have messages', () => {
71+
expect(form.find('[ng-messages]').length).toBe(1);
72+
});
73+
74+
it('should have min date', () => {
75+
expect(element.attr('md-min-date')).toBe('to.minDate');
76+
});
77+
78+
it('should have max date', () => {
79+
expect(element.attr('md-max-date')).toBe('to.maxDate');
80+
});
81+
82+
it('should have date filter', () => {
83+
expect(element.attr('md-date-filter')).toBe('to.filterDate');
84+
});
85+
86+
});

0 commit comments

Comments
 (0)