Debian Codegraph @

tests/testthat/test-html-dependencies.R

raw
1 # Disable sass cache
2 local_disable_cache()
3
4 library(htmltools)
5 dep1 <- htmlDependency(
6 name = "fake1",
7 version = "1.0.0",
8 src = ""
9 )
10 dep2 <- htmlDependency(
11 name = "fake2",
12 version = "1.0.0",
13 src = ""
14 )
15
16 test_that("sass()/as_sass() relay html dependencies", {
17 scss <- attachDependencies(list("body{color: green}"), dep1)
18 # Test that the print methods also relay
19 expect_snapshot(sass(scss), cran = TRUE)
20 expect_snapshot(as_sass(scss), cran = TRUE)
21 tmpcss <- tempfile(fileext = ".css")
22 on.exit(unlink(tmpcss), add = TRUE)
23 expect_equal(htmlDependencies(sass(scss)), list(dep1))
24 })
25
26 test_that("sass() relays sass_layer()'s html dependencies", {
27 layer1 <- sass_layer(defaults = "body{color: green}", html_deps = dep1)
28 input1 <- list(layer1, "body{color: red}")
29 expect_equal(htmlDependencies(sass(input1)), list(dep1))
30 layer2 <- sass_layer(defaults = "body{color: blue}", html_deps = dep2)
31 input2 <- sass_bundle(layer1, layer2)
32 expect_equal(htmlDependencies(sass(input2)), list(dep1, dep2))
33 })