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

Commit 707d56c

Browse files
author
Kamil Kisiela
committed
refactor(slider): remove bound from min, max and step ngModel attibutes
1 parent fd16909 commit 707d56c

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/types/slider/slider.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ export default (formlyConfigProvider) => {
77
defaultOptions: {
88
ngModelAttrs: {
99
min: {
10-
bound: 'min',
1110
attribute: 'min'
1211
},
1312
max: {
14-
bound: 'max',
1513
attribute: 'max'
1614
},
1715
step: {
18-
bound: 'step',
1916
attribute: 'step'
2017
},
2118
discrete: {

tests/types/slider-spec.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@ describe("formlyMaterial - slider type", () => {
1212
let form;
1313
let element;
1414
let field;
15+
const fieldConfig = {
16+
key: 'testField',
17+
type: 'slider',
18+
templateOptions: {
19+
label: 'test field',
20+
min: 1,
21+
max: 5,
22+
step: 0.5,
23+
discrete: true
24+
}
25+
};
1526
//
1627
// helpers
1728
//
1829

1930
function compile(options) {
2031
$scope = $rootScope.$new();
21-
$scope.fields = [angular.merge({}, {
22-
key: 'testField',
23-
type: 'slider',
24-
templateOptions: {
25-
label: 'test field',
26-
min: 1,
27-
max: 5,
28-
step: 0.5,
29-
discrete: true
30-
}
31-
}, options)];
32+
$scope.fields = [angular.merge({}, fieldConfig, options)];
3233

3334
form = $compile(testUtils.getFormTemplate())($scope);
3435
$scope.$digest();
@@ -57,19 +58,22 @@ describe("formlyMaterial - slider type", () => {
5758
});
5859

5960
it('should support min option', () => {
60-
expect(parseFloat(element.attr('min'))).toEqual(field.templateOptions.min);
61+
expect(parseFloat(element.attr('min'))).toEqual(fieldConfig.templateOptions.min);
6162
});
6263

6364
it('should support max option', () => {
64-
expect(parseFloat(element.attr('max'))).toEqual(field.templateOptions.max);
65+
expect(parseFloat(element.attr('max'))).toEqual(fieldConfig.templateOptions.max);
6566
});
6667

6768
it('should support step option', () => {
68-
expect(parseFloat(element.attr('step'))).toEqual(field.templateOptions.step);
69+
expect(parseFloat(element.attr('step'))).toEqual(fieldConfig.templateOptions.step);
6970
});
7071

7172
it('should support discrete option', () => {
73+
const scope = angular.element(element).scope();
74+
7275
expect(element.attr('md-discrete')).toEqual("options.templateOptions['discrete']");
76+
expect(scope.options.templateOptions.discrete).toBe(fieldConfig.templateOptions.discrete);
7377
});
7478

7579
});

0 commit comments

Comments
 (0)