From 93b055d23a658db9cac63c5e47ba408353cb48e3 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Tue, 27 Dec 2022 11:45:28 -0600 Subject: [PATCH] Add integration tests for text-offset Includes a test for the value of text-offset to be an expression. This test passes, which closes #1899. --- .../style-spec/tests/text-offset.input.json | 92 +++++++++++++++++++ .../style-spec/tests/text-offset.output.json | 6 ++ 2 files changed, 98 insertions(+) create mode 100644 test/integration/style-spec/tests/text-offset.input.json create mode 100644 test/integration/style-spec/tests/text-offset.output.json diff --git a/test/integration/style-spec/tests/text-offset.input.json b/test/integration/style-spec/tests/text-offset.input.json new file mode 100644 index 00000000000..9af0db1569d --- /dev/null +++ b/test/integration/style-spec/tests/text-offset.input.json @@ -0,0 +1,92 @@ +{ + "version": 8, + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "sources": { + "point": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "font-scale-override": 2.0, + "text-font-override": ["Arial"] + }, + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + } + } + ] + } + } + }, + "layers": [ + { + "id": "numeric offset - valid", + "type": "symbol", + "source": "point", + "layout": { + "text-offset": [ + 10, + 5 + ] + } + }, + { + "id": "numeric offset with negative values - valid", + "type": "symbol", + "source": "point", + "layout": { + "text-offset": [ + -10, + -5 + ] + } + }, + { + "id": "numeric offset with three numbers - invalid", + "type": "symbol", + "source": "point", + "layout": { + "text-offset": [ + 0, + 0, + 0 + ] + } + }, + { + "id": "expression get - valid", + "type": "symbol", + "source": "point", + "layout": { + "text-offset": [ + "get", + "population" + ] + } + }, + { + "id": "expression interpolate - valid", + "type": "symbol", + "source": "point", + "layout": { + "text-offset": [ + "interpolate", + ["linear"], + ["zoom"], + 16, + ["literal", [0, 1]], + 17, + ["literal", [0, 2]], + 18, + ["literal", [0, 3]], + 19, + ["literal", [0, 4]] + ] + } + } + ] +} diff --git a/test/integration/style-spec/tests/text-offset.output.json b/test/integration/style-spec/tests/text-offset.output.json new file mode 100644 index 00000000000..3c0c97b3868 --- /dev/null +++ b/test/integration/style-spec/tests/text-offset.output.json @@ -0,0 +1,6 @@ +[ + { + "message": "layers[2].layout.text-offset: array length 2 expected, length 3 found", + "line": 53 + } +]