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

Commit 6bec26e

Browse files
author
Kamil Kisiela
committed
test(slider): basic functionality
1 parent b014b74 commit 6bec26e

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

package.js

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

tests/client/types/slider-spec.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
describe("formlyMaterial - slider 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: 'slider',
22+
templateOptions: {
23+
label: 'test field',
24+
min: 1,
25+
max: 5,
26+
step: 0.5,
27+
discrete: true
28+
}
29+
}, options)];
30+
31+
form = $compile(testUtils.formTemplate)($scope);
32+
$scope.$digest();
33+
field = $scope.fields[0];
34+
element = form.find('[ng-model]');
35+
}
36+
37+
//
38+
// tests
39+
//
40+
41+
beforeEach(() => {
42+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
43+
module('testApp');
44+
45+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
46+
$compile = _$compile_;
47+
$rootScope = _$rootScope_;
48+
formlyConfig = _formlyConfig_;
49+
});
50+
51+
const types = ['slider'];
52+
53+
types.forEach((type) => {
54+
testUtils.fixTypeTemplateUrl(formlyConfig, type);
55+
});
56+
57+
compile();
58+
});
59+
60+
it('should be md-slider element', () => {
61+
expect(element[0].nodeName).toBe('MD-SLIDER');
62+
});
63+
64+
it('should support min option', () => {
65+
expect(parseFloat(element.attr('min'))).toEqual(field.templateOptions.min);
66+
});
67+
68+
it('should support max option', () => {
69+
expect(parseFloat(element.attr('max'))).toEqual(field.templateOptions.max);
70+
});
71+
72+
it('should support step option', () => {
73+
expect(parseFloat(element.attr('step'))).toEqual(field.templateOptions.step);
74+
});
75+
76+
it('should support discrete option', () => {
77+
expect(element.attr('md-discrete')).toEqual("options.templateOptions['discrete']");
78+
});
79+
80+
});

0 commit comments

Comments
 (0)