| 1 |
# Disable sass cache |
| 2 |
local_disable_cache() |
| 3 |
|
| 4 |
test_that("indent width works", { |
| 5 |
scss <- "foo { margin: 122px * .3; }" |
| 6 |
css_default <- sass(scss) |
| 7 |
|
| 8 |
width <- 4 |
| 9 |
css_width <- sass(scss, options = sass_options(indent_width = width)) |
| 10 |
expect_equal( |
| 11 |
nchar(css_default) + width - 2, |
| 12 |
nchar(css_width) |
| 13 |
) |
| 14 |
}) |
| 15 |
|
| 16 |
test_that("indent as tabs works", { |
| 17 |
scss <- "foo { margin: 122px * .3; }" |
| 18 |
css <- sass(scss, options = sass_options(indent_width = 1, indent_type = "tab")) |
| 19 |
expect_equal( |
| 20 |
strsplit(css, "")[[1]][7], |
| 21 |
"\t" |
| 22 |
) |
| 23 |
}) |
| 24 |
|
| 25 |
test_that("linefeed works", { |
| 26 |
scss <- "foo { margin: 122px * .3; }" |
| 27 |
css_lf <- sass(scss) |
| 28 |
|
| 29 |
expect_equal( |
| 30 |
strsplit(css_lf, "")[[1]][6], |
| 31 |
"\n" |
| 32 |
) |
| 33 |
|
| 34 |
css_cr <- sass(scss, options = sass_options(linefeed = "cr")) |
| 35 |
|
| 36 |
expect_equal( |
| 37 |
strsplit(css_cr, "")[[1]][6], |
| 38 |
"\r" |
| 39 |
) |
| 40 |
|
| 41 |
css_crlf <- sass(scss, options = sass_options(linefeed = "crlf")) |
| 42 |
|
| 43 |
expect_equal( |
| 44 |
paste0(strsplit(css_crlf, "")[[1]][6:7], collapse = ""), |
| 45 |
"\r\n" |
| 46 |
) |
| 47 |
|
| 48 |
css_crlf <- sass(scss, options = sass_options(linefeed = "lfcr")) |
| 49 |
|
| 50 |
expect_equal( |
| 51 |
paste0(strsplit(css_crlf, "")[[1]][6:7], collapse = ""), |
| 52 |
"\n\r" |
| 53 |
) |
| 54 |
}) |
| 55 |
|
| 56 |
test_that("precision works", { |
| 57 |
scss <- "foo { margin: 1px * 0.1234567891; }" |
| 58 |
num_chars_no_precision <- 23 |
| 59 |
css <- sass(scss) |
| 60 |
|
| 61 |
expect_equal( |
| 62 |
num_chars_no_precision + 6, |
| 63 |
nchar(css) |
| 64 |
) |
| 65 |
|
| 66 |
css <- sass(scss, options = sass_options(precision = 0)) |
| 67 |
expect_equal( |
| 68 |
num_chars_no_precision, |
| 69 |
nchar(css) |
| 70 |
) |
| 71 |
|
| 72 |
css <- sass(scss, options = sass_options(precision = 10)) |
| 73 |
expect_equal( |
| 74 |
num_chars_no_precision + 11, |
| 75 |
nchar(css) |
| 76 |
) |
| 77 |
}) |
| 78 |
|
| 79 |
test_that("source_comments work", { |
| 80 |
expect_lt( |
| 81 |
nchar(sass(sass_file("test-compile.scss"))), |
| 82 |
nchar(sass(sass_file("test-compile.scss"), sass_options(source_comments = TRUE))) |
| 83 |
) |
| 84 |
}) |