@@ -8,7 +8,7 @@ describe('Turbocarto preprocessor', function () {
8
8
// CARTO might be slow sometime...
9
9
jest . setTimeout ( 40000 )
10
10
11
- it ( 'must transform Trubocarto to CartoCSS' , async ( ) => {
11
+ it ( 'must transform Trubocarto with quantiles to CartoCSS' , async ( ) => {
12
12
SqlApiDatasource . prototype . querySummaryStats = jest . fn ( ) . mockImplementationOnce ( async ( ) => {
13
13
return [ 1 , 2 , 3 , 4 , 5 ]
14
14
} ) ;
@@ -18,4 +18,37 @@ describe('Turbocarto preprocessor', function () {
18
18
const cartocss = await cl . turbocarto . turbocartoToCartocss ( turbocarto , sql )
19
19
expect ( cartocss ) . toBe ( '#layer { polygon-fill: #ffffb2; [ tabelle1_e > 1 ] { polygon-fill: #fecc5c } [ tabelle1_e > 2 ] { polygon-fill: #fd8d3c } [ tabelle1_e > 3 ] { polygon-fill: #f03b20 } [ tabelle1_e > 4 ] { polygon-fill: #bd0026 } }' )
20
20
} ) ;
21
+
22
+ it ( 'must transform Trubocarto with equals to CartoCSS' , async ( ) => {
23
+ SqlApiDatasource . prototype . querySummaryStats = jest . fn ( ) . mockImplementationOnce ( async ( ) => {
24
+ return [ 1 , 2 , 3 , 4 , 5 ]
25
+ } ) ;
26
+
27
+ const sql = 'SELECT * FROM "erde_pop_2015"'
28
+ const turbocarto = '#layer { polygon-fill: ramp([tabelle1_e], (#ffffb2, #fecc5c, #fd8d3c, #f03b20, #bd0026), equals); }'
29
+ const cartocss = await cl . turbocarto . turbocartoToCartocss ( turbocarto , sql )
30
+ expect ( cartocss ) . toBe ( '#layer { polygon-fill: #ffffb2; [ tabelle1_e > 1 ] { polygon-fill: #fecc5c } [ tabelle1_e > 2 ] { polygon-fill: #fd8d3c } [ tabelle1_e > 3 ] { polygon-fill: #f03b20 } [ tabelle1_e > 4 ] { polygon-fill: #bd0026 } }' )
31
+ } ) ;
32
+
33
+ it ( 'must transform Trubocarto with jenks to CartoCSS' , async ( ) => {
34
+ SqlApiDatasource . prototype . querySummaryStats = jest . fn ( ) . mockImplementationOnce ( async ( ) => {
35
+ return [ 1 , 2 , 3 , 4 , 5 ]
36
+ } ) ;
37
+
38
+ const sql = 'SELECT * FROM "erde_pop_2015"'
39
+ const turbocarto = '#layer { polygon-fill: ramp([table], (#ffffb2, #fecc5c, #fd8d3c, #f03b20, #bd0026), jenks); }'
40
+ const cartocss = await cl . turbocarto . turbocartoToCartocss ( turbocarto , sql )
41
+ expect ( cartocss ) . toBe ( '#layer { polygon-fill: #ffffb2; [ table > 1 ] { polygon-fill: #fecc5c } [ table > 2 ] { polygon-fill: #fd8d3c } [ table > 3 ] { polygon-fill: #f03b20 } [ table > 4 ] { polygon-fill: #bd0026 } }' )
42
+ } ) ;
43
+
44
+ it ( 'must transform Trubocarto with headtails to CartoCSS' , async ( ) => {
45
+ SqlApiDatasource . prototype . querySummaryStats = jest . fn ( ) . mockImplementationOnce ( async ( ) => {
46
+ return [ 1 , 2 , 3 ]
47
+ } ) ;
48
+
49
+ const sql = 'SELECT * FROM "erde_pop_2015"'
50
+ const turbocarto = '#layer { polygon-fill: ramp([tabelle1_e], (#ffffb2, #fecc5c, #fd8d3c), headtails); }'
51
+ const cartocss = await cl . turbocarto . turbocartoToCartocss ( turbocarto , sql )
52
+ expect ( cartocss ) . toBe ( '#layer { polygon-fill: #ffffb2; [ tabelle1_e > 1 ] { polygon-fill: #fecc5c } [ tabelle1_e > 2 ] { polygon-fill: #fd8d3c } }' )
53
+ } ) ;
21
54
} ) ;
0 commit comments