tests/testthat/test-layers-list.R

# Disable sass cache
local_disable_cache()

body_rule <- "body { background-color: $color; color: my_invert($color); }"

blue <- list(color = "blue !default")
red <- list(color = "red !default")
green <- list(color = "green !default")
core <- sass_layer(
  defaults = blue,
  functions = "@function my_invert($color, $amount: 100%) {
    $inverse: change-color($color, $hue: hue($color) + 180);
    @return mix($inverse, $color, $amount);
  }",
  rules = body_rule
)

test_that("sass_layer is equivalent to sass", {
  expect_equal(
    sass(core),
    sass(list(blue, "body { background-color: $color; color: yellow; }")),
    ignore_attr = TRUE
  )
})

Try the sass package in your browser

Any scripts or data that you put into this service are public.

sass documentation built on May 29, 2024, 11:51 a.m.