@@ -12,23 +12,24 @@ describe("formlyMaterial - slider type", () => {
12
12
let form ;
13
13
let element ;
14
14
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
+ } ;
15
26
//
16
27
// helpers
17
28
//
18
29
19
30
function compile ( options ) {
20
31
$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 ) ] ;
32
33
33
34
form = $compile ( testUtils . getFormTemplate ( ) ) ( $scope ) ;
34
35
$scope . $digest ( ) ;
@@ -57,19 +58,22 @@ describe("formlyMaterial - slider type", () => {
57
58
} ) ;
58
59
59
60
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 ) ;
61
62
} ) ;
62
63
63
64
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 ) ;
65
66
} ) ;
66
67
67
68
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 ) ;
69
70
} ) ;
70
71
71
72
it ( 'should support discrete option' , ( ) => {
73
+ const scope = angular . element ( element ) . scope ( ) ;
74
+
72
75
expect ( element . attr ( 'md-discrete' ) ) . toEqual ( "options.templateOptions['discrete']" ) ;
76
+ expect ( scope . options . templateOptions . discrete ) . toBe ( fieldConfig . templateOptions . discrete ) ;
73
77
} ) ;
74
78
75
79
} ) ;
0 commit comments