Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic tests and validation for "formatted".
- Loading branch information
Showing
10 changed files
with
242 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow | ||
|
||
import ValidationError from '../error/validation_error'; | ||
import validateExpression from './validate_expression'; | ||
import validateString from './validate_string'; | ||
|
||
export default function validateFormatted(options: any) { | ||
if (validateString(options).length === 0) { | ||
return []; | ||
} | ||
|
||
return validateExpression(options); | ||
} |
88 changes: 88 additions & 0 deletions
88
test/integration/expression-tests/concat/formatted/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"expression": [ | ||
"concat", | ||
"a", | ||
[ | ||
"formatted", | ||
"b", | ||
{ | ||
"font-scale": 2 | ||
} | ||
], | ||
[ | ||
"formatted", | ||
"c", | ||
{ | ||
"text-font": [ | ||
"literal", | ||
[ | ||
"a", | ||
"b" | ||
] | ||
] | ||
} | ||
] | ||
], | ||
"inputs": [ | ||
[ | ||
{}, | ||
{} | ||
] | ||
], | ||
"expected": { | ||
"compiled": { | ||
"result": "success", | ||
"isFeatureConstant": true, | ||
"isZoomConstant": true, | ||
"type": "string" | ||
}, | ||
"outputs": [ | ||
{ | ||
"sections": [ | ||
{ | ||
"text": "a", | ||
"scale": null, | ||
"fontStack": null | ||
}, | ||
{ | ||
"text": "b", | ||
"scale": 2, | ||
"fontStack": null | ||
}, | ||
{ | ||
"text": "c", | ||
"scale": null, | ||
"fontStack": "a,b" | ||
} | ||
] | ||
} | ||
], | ||
"serialized": [ | ||
"concat", | ||
[ | ||
"formatted", | ||
"a", | ||
{ | ||
"font-scale": null, | ||
"text-font": null | ||
} | ||
], | ||
[ | ||
"formatted", | ||
"b", | ||
{ | ||
"font-scale": 2, | ||
"text-font": null | ||
} | ||
], | ||
[ | ||
"formatted", | ||
"c", | ||
{ | ||
"font-scale": null, | ||
"text-font": ["literal", ["a", "b"]] | ||
} | ||
] | ||
] | ||
} | ||
} |
Binary file added
BIN
+612 Bytes
test/integration/render-tests/text-field/formatted-line/expected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions
56
test/integration/render-tests/text-field/formatted-line/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"version": 8, | ||
"metadata": { | ||
"test": { | ||
"height": 256 | ||
} | ||
}, | ||
"center": [ | ||
13.418056, | ||
52.499167 | ||
], | ||
"zoom": 14, | ||
"sources": { | ||
"mapbox": { | ||
"type": "vector", | ||
"maxzoom": 14, | ||
"tiles": [ | ||
"local://tiles/{z}-{x}-{y}.mvt" | ||
] | ||
} | ||
}, | ||
"glyphs": "local://glyphs/{fontstack}/{range}.pbf", | ||
"layers": [ | ||
{ | ||
"id": "background", | ||
"type": "background", | ||
"paint": { | ||
"background-color": "white" | ||
} | ||
}, | ||
{ | ||
"id": "literal", | ||
"type": "symbol", | ||
"source": "mapbox", | ||
"source-layer": "road_label", | ||
"layout": { | ||
"symbol-placement": "line", | ||
"text-allow-overlap": true, | ||
"text-ignore-placement": true, | ||
"text-field": ["concat", | ||
["formatted", ["get", "name"], { "font-scale": 1.2 }], | ||
" - ", | ||
["formatted", ["get", "class"], { "font-scale": 0.8, "text-font": ["literal", [ "NotoCJK" ]] }] | ||
], | ||
"text-font": [ | ||
"Open Sans Semibold", | ||
"Arial Unicode MS Bold" | ||
], | ||
"text-size": 10 | ||
}, | ||
"paint": { | ||
"text-opacity": 1 | ||
} | ||
} | ||
] | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions
53
test/integration/render-tests/text-field/formatted/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"version": 8, | ||
"metadata": { | ||
"test": { | ||
"height": 256, | ||
"width": 256 | ||
} | ||
}, | ||
"center": [ 0, 0 ], | ||
"zoom": 0, | ||
"sources": { | ||
"point": { | ||
"type": "geojson", | ||
"data": { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"name": "Napoli", | ||
"name_en": "Naples" | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ 0, 0 ] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"glyphs": "local://glyphs/{fontstack}/{range}.pbf", | ||
"layers": [ | ||
{ | ||
"id": "text", | ||
"type": "symbol", | ||
"source": "point", | ||
"layout": { | ||
"text-field": ["concat", | ||
["formatted", ["get", "name_en"], { "font-scale": 1.5 }], | ||
["formatted", "Italy", { "font-scale": 0.5} ], | ||
"\n", | ||
["formatted", ["get", "name"], { "font-scale": 0.5, "text-font": ["literal", [ "NotoCJK" ]] }] | ||
], | ||
"text-font": [ | ||
"Open Sans Semibold", | ||
"Arial Unicode MS Bold" | ||
], | ||
"text-size": 32 | ||
} | ||
} | ||
] | ||
} |