Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
229 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ | ||
^codecov\.yml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(dcamodules) | ||
|
||
test_check("dcamodules") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
test_that("shinyButton works", { | ||
btn <- shinyButton( | ||
"test-id", "test-button", | ||
style = "color: red;" | ||
) | ||
|
||
expect_identical(btn[[1]]$attribs$id, "test-id") | ||
expect_identical(btn[[1]]$attribs$class, "btn btn-default action-button dca-shiny-btn") | ||
expect_identical(btn[[1]]$attribs$style, "color: red;") | ||
expect_identical(btn[[2]]$stylesheet, "main.min.css") | ||
}) | ||
|
||
test_that("arrowButton works", { | ||
btn <- arrowButton( | ||
"test-id", | ||
style = "color: red;" | ||
) | ||
expect_identical(btn[[1]]$attribs$id, "test-id") | ||
expect_identical( | ||
purrr::map_chr(btn[[1]]$children[[1]][[1]], ~ .x$attribs$class), | ||
rep("fa fa-angle-left", 3) | ||
) | ||
expect_identical(btn[[1]]$attribs$class, "btn btn-default action-button dca-left-btn") | ||
expect_identical(btn[[1]]$attribs$style, "color: red;") | ||
expect_identical(btn[[2]]$stylesheet, "main.min.css") | ||
}) | ||
|
||
test_that("mediaButton works", { | ||
btn <- mediaButton( | ||
"google", | ||
style = "color: red;" | ||
) | ||
|
||
expect_true(grepl("fa-google", btn[[1]]$children[[1]]$attribs$class)) | ||
expect_true(is.null(btn[[1]]$attribs$link)) | ||
expect_identical(btn[[1]]$attribs$class, "dca-icon-btn") | ||
expect_identical(btn[[1]]$attribs$style, "color: red;") | ||
expect_identical(btn[[2]]$stylesheet, "main.min.css") | ||
}) | ||
|
||
test_that("paletteButton works", { | ||
btn <- paletteButton( | ||
"test-id", "red", | ||
style = "color: red;" | ||
) | ||
expect_identical(btn[[1]]$attribs$id, "test-id") | ||
expect_identical(btn[[1]]$attribs$class, "action-button dca-palette-btn") | ||
expect_identical(btn[[1]]$children[[1]]$attribs$style, "color: red;") | ||
expect_identical(btn[[1]]$attribs$style, "color: red;") | ||
expect_identical(btn[[2]]$stylesheet, "main.min.css") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test_that("dcaFooter works", { | ||
footer <- dcaFooter("default footer", height = "200px") | ||
expect_identical(footer$attribs$class, "dca-footer-placeholder") | ||
expect_identical(footer$attribs$style, "height: 200px;") | ||
expect_identical(footer$children[[1]]$attribs$class, "dca-footer") | ||
expect_identical(footer$children[[1]]$attribs$style, "max-height: 200px;") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
test_that("use_dca_waiter works", { | ||
deps <- use_dca_waiter() | ||
expect_length(deps, 2) | ||
expect_identical(deps[[2]]$stylesheet, "main.min.css") | ||
}) | ||
|
||
test_that("waiter works", { | ||
library(shiny) | ||
library(shinydashboard) | ||
library(dcamodules) | ||
|
||
ui <- dashboardPage( | ||
dashboardHeader(), | ||
dashboardSidebar(), | ||
dashboardBody( | ||
use_dca_waiter(), | ||
# landing | ||
dca_waiter("show", is.landing = TRUE) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
observeEvent(input$waiter, { | ||
t <- 0 | ||
# not certified | ||
dca_waiter("update", is.landing = TRUE, is.certified = FALSE, sleep = t) | ||
# not enought permission | ||
dca_waiter("update", is.landing = TRUE, is.permission = FALSE, sleep = t) | ||
# success login | ||
dca_waiter("update", is.landing = TRUE, sleep = t) | ||
# simple waiter screens | ||
dca_waiter("show", sleep = t) | ||
dca_waiter("update", sleep = t, is.stop = TRUE) | ||
dca_waiter("hide", sleep = t) | ||
}) | ||
} | ||
|
||
testServer(server, { | ||
# iniate all waiters in server | ||
session$setInputs(waiter = 1) | ||
}) | ||
}) | ||
|
||
test_that("waiter warning works", { | ||
expect_warning( | ||
dca_waiter("show", is.landing = TRUE, is.stop = TRUE), | ||
"'is.stop' is not used when 'is.landing' is TRUE" | ||
) | ||
}) | ||
|
||
test_that("spin_logo works", { | ||
svg_spinner <- spin_logo("synapse") | ||
png_spinner <- spin_logo("htan") | ||
expect_identical(class(svg_spinner[[1]]), "shiny.tag") | ||
expect_identical(class(png_spinner[[1]]), "shiny.tag") | ||
expect_identical(svg_spinner[[1]]$attribs$class, "dca-logo-spin") | ||
expect_identical(png_spinner[[1]]$attribs$class, "dca-logo-spin") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("multiplication works", { | ||
expect_equal(2 * 2, 4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("multiplication works", { | ||
expect_equal(2 * 2, 4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("multiplication works", { | ||
expect_equal(2 * 2, 4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
test_that("get_tab_names works", { | ||
tab_object <- tabItems( | ||
tabItem(tabName = "tab1"), | ||
tabItem(tabName = "tab2"), | ||
tabItem(tabName = "tab3") | ||
) | ||
res <- get_tab_names(tab_object) | ||
expect_identical(res, c("tab1", "tab2", "tab3")) | ||
}) | ||
|
||
test_that("var_to_server works", { | ||
ui <- var_to_server("values", 1:3) | ||
expect_true(grepl("dca-remove", ui$attribs$class)) | ||
# TODO: add test on values in server | ||
}) | ||
|
||
test_that("insert_attribute with single tag works", { | ||
tag <- insert_attribute( | ||
div(), | ||
id = "test-id" | ||
) | ||
tag2 <- insert_attribute( | ||
tags$div(list(tags$i(), tags$i())), | ||
id = "test-id", | ||
pos = 2 | ||
) | ||
expect_identical(tag$attribs$id, "test-id") | ||
expect_identical(tag2$children[[1]][[2]]$attribs$id, "test-id") | ||
expect_identical(tag2$children[[1]][[1]]$attribs$id, NULL) | ||
}) | ||
|
||
test_that("drop_empty with drop = 'all' works", { | ||
test_data <- c("real", "null", NULL, NA, " ") | ||
res_all <- drop_empty(test_data) | ||
res_na <- drop_empty(test_data, drop = "na") | ||
res_null <- drop_empty(test_data, drop = "null") | ||
res_blank <- drop_empty(test_data, drop = "blank") | ||
expect_identical(res_all, "real") | ||
expect_identical(res_na, c("real", "null", " ")) | ||
expect_identical(res_null, c("real", NA, " ")) | ||
expect_identical(res_blank, c("real", "null", NA)) | ||
}) |