@@ -22,7 +22,7 @@ describe('Gauge component', () => {
22
22
]
23
23
} ) ;
24
24
25
- test ( 'render all data' , ( ) => {
25
+ test ( 'render data from thresholds ' , ( ) => {
26
26
spectator = createHost ( `<ht-gauge [value]="value" [maxValue]="maxValue" [thresholds]="thresholds"></ht-gauge>` , {
27
27
hostProps : {
28
28
value : 80 ,
@@ -57,13 +57,74 @@ describe('Gauge component', () => {
57
57
maxValue : 100 ,
58
58
valueArc :
59
59
'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,0,1,129.88160257335298,-75.03845222935763A7.5,7.5,0,0,1,126.79245119273195,-64.60398068647702L126.79245119273195,-64.60398068647702A7.5,7.5,0,0,1,116.8934423160177,-67.5346070064219A135,135,0,0,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z' ,
60
- threshold : {
61
- color : '#9e4c41' ,
62
- end : 90 ,
63
- label : 'Medium' ,
64
- start : 60
60
+ color : '#9e4c41' ,
61
+ label : 'Medium'
62
+ }
63
+ } ) ;
64
+ } ) ;
65
+
66
+ test ( 'render data from default values' , ( ) => {
67
+ spectator = createHost (
68
+ `<ht-gauge [value]="value" [maxValue]="maxValue" [defaultColor]="defaultColor" [defaultLabel]="defaultLabel"></ht-gauge>` ,
69
+ {
70
+ hostProps : {
71
+ value : 80 ,
72
+ maxValue : 100 ,
73
+ defaultColor : '#9e4c41' ,
74
+ defaultLabel : 'Medium'
65
75
}
66
76
}
77
+ ) ;
78
+ spectator . component . onLayoutChange ( ) ;
79
+ expect ( spectator . component . rendererData ) . toEqual ( {
80
+ backgroundArc :
81
+ 'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,1,1,146.73136591755903,31.143317998687948A7.5,7.5,0,0,1,137.45365478341216,36.83059579592157L137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,132.05822932580313,28.02898619881916A135,135,0,1,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z' ,
82
+ origin : {
83
+ x : 150 ,
84
+ y : 150
85
+ } ,
86
+ radius : 150 ,
87
+ data : {
88
+ value : 80 ,
89
+ maxValue : 100 ,
90
+ valueArc :
91
+ 'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,0,1,129.88160257335298,-75.03845222935763A7.5,7.5,0,0,1,126.79245119273195,-64.60398068647702L126.79245119273195,-64.60398068647702A7.5,7.5,0,0,1,116.8934423160177,-67.5346070064219A135,135,0,0,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z' ,
92
+ color : '#9e4c41' ,
93
+ label : 'Medium'
94
+ }
95
+ } ) ;
96
+ } ) ;
97
+
98
+ test ( 'render data without default values or thresholds' , ( ) => {
99
+ spectator = createHost ( `<ht-gauge [value]="value" [maxValue]="maxValue"></ht-gauge>` , {
100
+ hostProps : {
101
+ value : 80 ,
102
+ maxValue : 100
103
+ }
104
+ } ) ;
105
+ spectator . component . onLayoutChange ( ) ;
106
+ expect ( spectator . component . rendererData ) . toEqual ( {
107
+ backgroundArc :
108
+ 'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,1,1,146.73136591755903,31.143317998687948A7.5,7.5,0,0,1,137.45365478341216,36.83059579592157L137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,132.05822932580313,28.02898619881916A135,135,0,1,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z' ,
109
+ origin : {
110
+ x : 150 ,
111
+ y : 150
112
+ } ,
113
+ radius : 150 ,
114
+ data : {
115
+ value : 80 ,
116
+ maxValue : 100 ,
117
+ valueArc :
118
+ 'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,0,1,129.88160257335298,-75.03845222935763A7.5,7.5,0,0,1,126.79245119273195,-64.60398068647702L126.79245119273195,-64.60398068647702A7.5,7.5,0,0,1,116.8934423160177,-67.5346070064219A135,135,0,0,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z' ,
119
+ color : Color . Blue5 ,
120
+ label : ''
121
+ }
67
122
} ) ;
68
123
} ) ;
124
+
125
+ test ( 'no render data when values are undefined' , ( ) => {
126
+ spectator = createHost ( `<ht-gauge></ht-gauge>` ) ;
127
+ spectator . component . onLayoutChange ( ) ;
128
+ expect ( spectator . component . rendererData ) . toBeUndefined ( ) ;
129
+ } ) ;
69
130
} ) ;
0 commit comments