Skip to content

Commit

Permalink
Get unit tests passing; R CMD check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Apr 12, 2021
1 parent 427e4e2 commit b77b29b
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 143 deletions.
2 changes: 1 addition & 1 deletion R/bs-dependencies.R
Expand Up @@ -342,7 +342,7 @@ as_bs_theme <- function(theme) {
# Also support `bs_theme_dependencies(version = '4')` and
# `bs_theme_dependencies(theme = 'bootswatch')`
if (length(theme) == 1) {
if (theme %in% c("4", "4-3", "4+3", "3")) {
if (theme %in% c(versions(), "4-3", "4+3")) {
return(bs_theme(version = theme))
} else {
return(bs_theme(bootswatch = theme))
Expand Down
2 changes: 1 addition & 1 deletion inst/css-precompiled/5/bootstrap.min.css

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions inst/lib/bsw5/.browserslistrc

This file was deleted.

11 changes: 0 additions & 11 deletions inst/lib/bsw5/.editorconfig

This file was deleted.

5 changes: 0 additions & 5 deletions inst/lib/bsw5/.gitattributes

This file was deleted.

17 changes: 0 additions & 17 deletions inst/lib/bsw5/.github/stale.yml

This file was deleted.

46 changes: 0 additions & 46 deletions inst/lib/bsw5/.github/workflows/ci.yml

This file was deleted.

11 changes: 0 additions & 11 deletions inst/lib/bsw5/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions inst/lib/bsw5/.stylelintignore

This file was deleted.

18 changes: 0 additions & 18 deletions inst/lib/bsw5/.stylelintrc

This file was deleted.

52 changes: 52 additions & 0 deletions tests/testthat/_snaps/zzzz-bs-sass/bs5-imports
@@ -0,0 +1,52 @@
/*!
* Bootstrap v5.0.0-beta3 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/

// scss-docs-start import-stack
// Configuration
@import "functions";
@import "variables";
@import "mixins";
@import "utilities";

// Layout & components
@import "root";
@import "reboot";
@import "type";
@import "images";
@import "containers";
@import "grid";
@import "tables";
@import "forms";
@import "buttons";
@import "transitions";
@import "dropdown";
@import "button-group";
@import "nav";
@import "navbar";
@import "card";
@import "accordion";
@import "breadcrumb";
@import "pagination";
@import "badge";
@import "alert";
@import "progress";
@import "list-group";
@import "close";
@import "toasts";
@import "modal";
@import "tooltip";
@import "popover";
@import "carousel";
@import "spinners";
@import "offcanvas";

// Helpers
@import "helpers";

// Utilities
@import "utilities/api";
// scss-docs-end import-stack
4 changes: 2 additions & 2 deletions tests/testthat/test-bs4-deps.R
Expand Up @@ -6,7 +6,7 @@ describe("Compiling against theme", {
resolved_css <- ".foo { background-color: #007bff; color: #fff; width: 120px; height: 120px; }"

# Compare bs_sass(input1) and sass(input2)
expect_bs4_equal <- function(input1, input2, options = sass_options(), theme = bs_theme()) {
expect_bs4_equal <- function(input1, input2, options = sass_options(), theme = bs_theme(version = 4)) {
expect_css(
sass_partial(input1, theme, options = options),
sass(input2, options = options)
Expand All @@ -26,7 +26,7 @@ describe("Compiling against theme", {
# Theme options are respected
expect_bs4_equal(
bs4_css, ".foo { background-color: #FF0000; color: #fff; width: 120px; height: 120px; }",
theme = bs_theme(primary = "red")
theme = bs_theme(version = 4, primary = "red")
)
# Unless they're not
expect_bs4_equal(bs4_css, resolved_css)
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/test-theme-base-colors.R
Expand Up @@ -213,23 +213,12 @@ test_that("theme-color('default') works as expected", {
".foo{color:theme-color('default')}", bs_theme(version = 4, secondary = "red")
)
expect_css(css, ".foo{color:#FF0000;}")
# and is removed completely without bs3compat
css <- sass::sass_partial(
".foo{color:theme-color('default')}", bs_theme(version = 4) %>% bs_remove("bs3compat")
)
expect_css(css, "")
expect_error(
sass::sass(
list(bs_theme(), ".foo { @extend .bg-default; }")
),
NA
)
expect_error(
sass::sass(
list(bs_theme() %>% bs_remove("bs3compat"), ".foo { @extend .bg-default; }")
),
"bg-default"
)
})

test_that("bs_get_contrast() works as expected", {
Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test-zzzz-bs-sass.R
Expand Up @@ -23,6 +23,11 @@ test_that("Can access the sass behind all versions and Bootswatch themes", {
# (and once we have, then this hash should be updated as well).
test_that("Make sure bootstrap.scss hasn't changed", {
expect_snapshot_file(
lib_file("bs", "scss", "bootstrap.scss")
lib_file("bs4", "scss", "bootstrap.scss"),
name = "bs4-imports"
)
expect_snapshot_file(
lib_file("bs5", "scss", "bootstrap.scss"),
name = "bs5-imports"
)
})
4 changes: 4 additions & 0 deletions tools/yarn_install.R
Expand Up @@ -215,6 +215,10 @@ with_dir(
file.remove(Sys.glob(file.path(bsw, "dist/*/bootstrap.css")))
file.remove(Sys.glob(file.path(bsw, "dist/*/bootstrap.min.css")))
unlink("bsw5/docs", recursive = TRUE)
# Remove hidden files
unlink(
dir(bsw, pattern = "^\\.[a-z]+", all.files = TRUE, full.names = TRUE), recursive = TRUE
)
}
file.remove(c(
Sys.glob("bsw3/*/bootstrap.css"),
Expand Down

0 comments on commit b77b29b

Please sign in to comment.