| 1 |
# Disable sass cache |
| 2 |
local_disable_cache() |
| 3 |
|
| 4 |
test_that(".scss file compiles", { |
| 5 |
expected <- "foo {\n margin: 36.6px;\n}\n\nbar {\n margin: 63px;\n}\n" |
| 6 |
class(expected) <- c("css", "html", "character") |
| 7 |
attr(expected, "html") <- TRUE |
| 8 |
|
| 9 |
expect_equal( |
| 10 |
sass(sass_file("test-compile.scss")), |
| 11 |
expected |
| 12 |
) |
| 13 |
}) |
| 14 |
|
| 15 |
test_that("string input compiles", { |
| 16 |
expected <- "foo {\n margin: 36.6px;\n}\n" |
| 17 |
class(expected) <- c("css", "html", "character") |
| 18 |
attr(expected, "html") <- TRUE |
| 19 |
|
| 20 |
expect_equal( |
| 21 |
sass("foo { margin: 122px * .3; }"), |
| 22 |
expected |
| 23 |
) |
| 24 |
}) |
| 25 |
|
| 26 |
test_that("character vector input compiles", { |
| 27 |
input <- c(".foo {\n color: red;\n}\n", ".bar {\n background-color: blue;\n}\n") |
| 28 |
expected <- paste(input, collapse = "\n") |
| 29 |
class(expected) <- c("css", "html", "character") |
| 30 |
attr(expected, "html") <- TRUE |
| 31 |
|
| 32 |
expect_equal(sass(input), expected) |
| 33 |
expect_equal(sass(as.list(input)), expected) |
| 34 |
}) |
| 35 |
|
| 36 |
test_that("named character vector throws warning", { |
| 37 |
expect_warning(sass(c(var = "foo{color: red}")), "named") |
| 38 |
}) |
| 39 |
|
| 40 |
test_that("sass compiles", { |
| 41 |
expected <- "foo {\n margin: 36.6px;\n}\n\nbar {\n margin: 63px;\n}\n" |
| 42 |
class(expected) <- c("css", "html", "character") |
| 43 |
attr(expected, "html") <- TRUE |
| 44 |
|
| 45 |
expect_equal( |
| 46 |
sass(sass_file("test-compile.sass"), sass_options(indented_syntax = TRUE)), |
| 47 |
expected |
| 48 |
) |
| 49 |
}) |
| 50 |
|
| 51 |
|
| 52 |
test_that("sass_partial() and sass() arguments match", { |
| 53 |
s <- formals(sass) |
| 54 |
s$input <- NULL |
| 55 |
|
| 56 |
sp <- formals(sass_partial) |
| 57 |
sp$rules <- NULL |
| 58 |
sp$bundle <- NULL |
| 59 |
|
| 60 |
expect_identical(s, sp) |
| 61 |
}) |