| @@ -100,19 +100,20 @@ list2css <- function(css) { | |||
| stop(msg, call. = FALSE) | |||
| } | |||
| purrr::map_chr(names(css), function(el) { | |||
| x <- purrr::imap_chr(css, function(rules, selector) { | |||
| paste( | |||
| sep = "\n", | |||
| el %.% " {", | |||
| selector %.% " {", | |||
| paste( | |||
| purrr::map_chr(names(css[[el]]), function(prop) { | |||
| " " %.% prop %.% ": " %.% css[[el]][[prop]] %.% ";" | |||
| purrr::imap_chr(rules, function(value, prop) { | |||
| " " %.% prop %.% ": " %.% value %.% ";" | |||
| }), | |||
| collapse = "\n" | |||
| ), | |||
| "}" | |||
| ) | |||
| }) | |||
| unname(x) | |||
| } | |||
| list2fonts <- function(fonts) { | |||
| @@ -166,6 +166,18 @@ describe("list2css()", { | |||
| "elements.+must be named.+body, thing.+have" | |||
| ) | |||
| }) | |||
| it("is okay for multiple entries with the same name", { | |||
| expect_equal( | |||
| list2css(list("a" = list(color = "red"), a = list(color = "blue"))), | |||
| c("a {\n color: red;\n}", "a {\n color: blue;\n}") | |||
| ) | |||
| expect_equal( | |||
| list2css(list("a" = list(color = "red", color = "blue"))), | |||
| c("a {\n color: red;\n color: blue;\n}") | |||
| ) | |||
| }) | |||
| }) | |||