Skip to content

Commit

Permalink
Add data-driven format option tests.
Browse files Browse the repository at this point in the history
"text-font" can't be data-driven because we need to be able to statically analyze set of required fonts.
  • Loading branch information
ChrisLoer committed Oct 9, 2018
1 parent 650635f commit 1b98c40
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"expression": [
"format",
"a",
{
"font-scale": ["get", "font-scale"]
}
],
"inputs": [
[{}, {"properties": {"font-scale": 1.5}}],
[{}, {"properties": {"font-scale": 0.5}}]
],
"expected": {
"compiled": {
"result": "success",
"isFeatureConstant": false,
"isZoomConstant": true,
"type": "formatted"
},
"outputs": [
{
"sections": [
{
"text": "a",
"scale": 1.5,
"fontStack": null
}
]
},
{
"sections": [
{
"text": "a",
"scale": 0.5,
"fontStack": null
}
]
}
],
"serialized": [
"format",
"a",
{
"font-scale": ["number", ["get", "font-scale"]]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"expression": [
"format",
"a",
{
"text-font": ["array", ["string", ["get", "text-font"]]]
}
],
"inputs": [
[{}, {"properties": {"text-font": "test"}}]
],
"expected": {
"compiled": {
"result": "error",
"errors": [
{
"error": "Expected array<string> but found array instead.",
"key": "[1]"
}
]
}
}
}

0 comments on commit 1b98c40

Please sign in to comment.