protomapr/tests/testthat/test-rules.R

38 lines
1.2 KiB
R
Raw Normal View History

2026-03-06 15:46:39 +11:00
test_that("pmPaintRule creates correct structure", {
sym <- pmPolygonSymbolizer(fill = "blue")
rule <- pmPaintRule("water", sym)
expect_equal(rule$dataLayer, "water")
expect_equal(rule$symbolizer$type, "polygon")
})
test_that("pmPaintRule handles zoom constraints", {
sym <- pmPolygonSymbolizer(fill = "gray")
rule <- pmPaintRule("buildings", sym, minzoom = 14, maxzoom = 18)
expect_equal(rule$minzoom, 14)
expect_equal(rule$maxzoom, 18)
})
test_that("pmPaintRule handles filters", {
sym <- pmLineSymbolizer(color = "orange")
rule <- pmPaintRule("roads", sym, filter = "feature.props.kind === 'highway'")
expect_equal(rule$filter, "feature.props.kind === 'highway'")
})
test_that("pmLabelRule creates correct structure", {
sym <- pmCenteredTextSymbolizer(font = "14px Arial", fill = "black")
rule <- pmLabelRule("places", sym)
expect_equal(rule$dataLayer, "places")
expect_equal(rule$symbolizer$type, "centeredText")
})
test_that("pmLabelRule handles filters", {
sym <- pmCenteredTextSymbolizer(font = "14px Arial", fill = "black")
rule <- pmLabelRule("places", sym, filter = "feature.props.kind === 'locality'")
expect_equal(rule$filter, "feature.props.kind === 'locality'")
})