@@ -20,7 +20,6 @@ describe('Worldmap', () => {
2020 beforeEach ( ( ) => {
2121 ctrl . data = new DataBuilder ( )
2222 . withCountryAndValue ( 'SE' , 1 )
23- . withDataRange ( 1 , 1 , 0 )
2423 . build ( ) ;
2524 ctrl . panel . circleMaxSize = '10' ;
2625 worldMap . drawCircles ( ) ;
@@ -46,7 +45,6 @@ describe('Worldmap', () => {
4645 ctrl . data = new DataBuilder ( )
4746 . withCountryAndValue ( 'SE' , 1 )
4847 . withCountryAndValue ( 'IE' , 2 )
49- . withDataRange ( 1 , 2 , 1 )
5048 . build ( ) ;
5149 ctrl . panel . circleMinSize = '2' ;
5250 ctrl . panel . circleMaxSize = '10' ;
@@ -76,7 +74,6 @@ describe('Worldmap', () => {
7674 ctrl . data = new DataBuilder ( )
7775 . withCountryAndValue ( 'SE' , 1 )
7876 . withCountryAndValue ( 'IE' , 2 )
79- . withDataRange ( 1 , 2 , 1 )
8077 . build ( ) ;
8178 ctrl . panel . circleMinSize = '2' ;
8279 ctrl . panel . circleMaxSize = '10' ;
@@ -100,7 +97,6 @@ describe('Worldmap', () => {
10097 . withCountryAndValue ( 'SE' , 1 )
10198 . withCountryAndValue ( 'IE' , 2 )
10299 . withCountryAndValue ( 'US' , 3 )
103- . withDataRange ( 1 , 3 , 2 )
104100 . withThresholdValues ( [ 2 ] )
105101 . build ( ) ;
106102 ctrl . panel . circleMinSize = '2' ;
@@ -146,7 +142,6 @@ describe('Worldmap', () => {
146142 . withCountryAndValue ( 'SE' , 1 )
147143 . withCountryAndValue ( 'IE' , 2 )
148144 . withCountryAndValue ( 'US' , null )
149- . withDataRange ( 1 , 3 , 2 )
150145 . withThresholdValues ( [ 2 ] )
151146 . build ( ) ;
152147 ctrl . panel . hideEmpty = true ;
@@ -164,7 +159,6 @@ describe('Worldmap', () => {
164159 . withCountryAndValue ( 'SE' , 1 )
165160 . withCountryAndValue ( 'IE' , 2 )
166161 . withCountryAndValue ( 'US' , 0 )
167- . withDataRange ( 1 , 3 , 2 )
168162 . withThresholdValues ( [ 2 ] )
169163 . build ( ) ;
170164 ctrl . panel . hideZero = true ;
@@ -185,7 +179,6 @@ describe('Worldmap', () => {
185179 . withCountryAndValue ( 'SE' , 1 )
186180 . withCountryAndValue ( 'IE' , 2 )
187181 . withCountryAndValue ( 'US' , 3 )
188- . withDataRange ( 1 , 3 , 2 )
189182 . withThresholdValues ( [ 2 ] )
190183 . build ( ) ;
191184
@@ -195,7 +188,6 @@ describe('Worldmap', () => {
195188 . withCountryAndValue ( 'SE' , 3 )
196189 . withCountryAndValue ( 'IE' , 2 )
197190 . withCountryAndValue ( 'US' , 1 )
198- . withDataRange ( 1 , 3 , 2 )
199191 . withThresholdValues ( [ 2 ] )
200192 . build ( ) ;
201193
@@ -227,15 +219,13 @@ describe('Worldmap', () => {
227219 . withCountryAndValue ( 'SE' , 1 )
228220 . withCountryAndValue ( 'IE' , 2 )
229221 . withCountryAndValue ( 'US' , 3 )
230- . withDataRange ( 1 , 3 , 2 )
231222 . withThresholdValues ( [ 2 ] )
232223 . build ( ) ;
233224
234225 worldMap . drawCircles ( ) ;
235226
236227 ctrl . data = new DataBuilder ( )
237228 . withCountryAndValue ( 'SE' , 2 )
238- . withDataRange ( 1 , 1 , 0 )
239229 . withThresholdValues ( [ 2 ] )
240230 . build ( ) ;
241231
@@ -322,7 +312,6 @@ describe('Worldmap', () => {
322312 . withCountryAndValue ( 'SE' , 1 , highVal )
323313 . withCountryAndValue ( 'IE' , 2 , avgVal )
324314 . withCountryAndValue ( 'US' , 1 , lowVal )
325- . withDataRange ( 0 , 100 , 50 )
326315 . withThresholdValues ( [ 33 , 66 ] )
327316 . build ( ) ;
328317 worldMap . drawCircles ( ) ;
@@ -387,4 +376,51 @@ describe('Worldmap', () => {
387376 worldMap = new WorldMap ( ctrl , document . getElementsByClassName ( 'mapcontainer' ) [ 0 ] ) ;
388377 worldMap . createMap ( ) ;
389378 }
379+
380+ describe ( 'when apply log is set' , ( ) => {
381+ const LOW = 1 ;
382+ const HIGH = 300000 ;
383+ const MID = 100 ;
384+
385+ const minCircleSize = 1 ;
386+ const maxCircleSize = 11 ;
387+ const midCircleSize = 4.651553264913736 ;
388+
389+
390+ beforeEach ( ( ) => {
391+ ctrl . data = new DataBuilder ( )
392+ . withCountryAndValue ( 'SE' , LOW )
393+ . withCountryAndValue ( 'IE' , MID )
394+ . withCountryAndValue ( 'US' , HIGH )
395+ . withThresholdValues ( [ 2 ] )
396+ . build ( ) ;
397+ ctrl . panel . circleMinSize = minCircleSize ;
398+ ctrl . panel . circleMaxSize = maxCircleSize ;
399+ ctrl . panel . isLogScale = true ;
400+ worldMap . drawCircles ( ) ;
401+ } ) ;
402+
403+ it ( 'should draw three circles on the map' , ( ) => {
404+ expect ( worldMap . circles . length ) . toBe ( 3 ) ;
405+ } ) ;
406+
407+ it ( 'should create a circle with min circle size for smallest value size' , ( ) => {
408+ expect ( worldMap . circles [ 0 ] . options . radius ) . toBe ( minCircleSize ) ;
409+ } ) ;
410+
411+ // log is used to highlight the smaller parts when there's a big deviant
412+ it ( 'should create a circle with intermediary circle size for mid value size' , ( ) => {
413+ expect ( worldMap . circles [ 1 ] . options . radius ) . toBe ( midCircleSize ) ;
414+ } ) ;
415+
416+ it ( 'should create a circle with max circle size for largest value size' , ( ) => {
417+ expect ( worldMap . circles [ 2 ] . options . radius ) . toBe ( maxCircleSize ) ;
418+ } ) ;
419+
420+ it ( 'should create circle popups with the second metrics there' , ( ) => {
421+ expect ( worldMap . circles [ 0 ] . _popup . _content ) . toBe ( `Sweden: ${ LOW } ` ) ;
422+ expect ( worldMap . circles [ 1 ] . _popup . _content ) . toBe ( `Ireland: ${ MID } ` ) ;
423+ expect ( worldMap . circles [ 2 ] . _popup . _content ) . toBe ( `United States: ${ HIGH } ` ) ;
424+ } ) ;
425+ } ) ;
390426} ) ;
0 commit comments