Skip to content

Commit

Permalink
Increase coverage, but also label more interactive parts with nocov
Browse files Browse the repository at this point in the history
  • Loading branch information
RiboRings committed Nov 25, 2024
1 parent 87bfa23 commit f2e05cb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion R/landing_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#' @importFrom utils data
.landing_page <- function(FUN, input, output, session) {

# nocov start
mia_datasets <- .import_datasets(-c(2, 5))

# nocov start
output$allPanels <- renderUI({

fluidPage(
Expand Down
2 changes: 2 additions & 0 deletions R/observers.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@
#' @importFrom shiny observeEvent
.create_launch_observers <- function(FUN, input, session, rObjects) {

# nocov start
observeEvent(input$launch, {

.launch_isee(FUN, input$panels, session, rObjects)

}, ignoreInit = TRUE, ignoreNULL = TRUE)
# nocov end

invisible(NULL)
}
27 changes: 15 additions & 12 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@
invokeRestart("muffleMessage")

})


# nocov start
lapply(messages, showNotification)
# nocov end

return(tse)
}

#' @rdname utils
#' @importFrom shiny showModal modalDialog
.print_message <- function(..., title = "Invalid input:"){
.print_message <- function(..., title = "Invalid input:") {

# nocov start
showModal(modalDialog(
title = title, ...,
easyClose = TRUE, footer = NULL
))

# nocov end
}

#' @rdname utils
Expand All @@ -64,25 +67,25 @@
#' @importFrom methods is
.check_panel <- function(se, panel_list, panel_class, panel_fun, wtext) {

no_keep <- unlist(lapply(panel_list, function(x) is(x, panel_class)))
no_keep <- unlist(lapply(panel_list, function(x) is(x, panel_class)))

if( any(no_keep) && (is.null(panel_fun(se)) || isEmpty(panel_fun(se))) ){
panel_list <- panel_list[!no_keep]
warning("no valid ", as.character(substitute(panel_fun)),
if( any(no_keep) && (is.null(panel_fun(se)) || isEmpty(panel_fun(se))) ){
panel_list <- panel_list[!no_keep]
warning("no valid ", as.character(substitute(panel_fun)),
" fields for ", panel_class, call. = FALSE)
}
}

return(panel_list)
return(panel_list)
}

#' @rdname utils
default_panels <- c("RowDataTable", "ColumnDataTable", "RowTreePlot",
"AbundancePlot", "AbundanceDensityPlot", "ReducedDimensionPlot",
"ComplexHeatmapPlot")
"AbundancePlot", "AbundanceDensityPlot", "ReducedDimensionPlot",
"ComplexHeatmapPlot")

#' @rdname utils
other_panels <- c("LoadingPlot", "ColumnTreePlot", "RDAPlot", "ColumnDataPlot",
"RowDataPlot")
"RowDataPlot")

#' @rdname utils
.actionbutton_biocstyle <- "color: #ffffff; background-color: #0092AC; border-color: #2e6da4"
5 changes: 5 additions & 0 deletions tests/testthat/test-miaDash.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_that("outputs", {

expect_no_error(miaDash())

})
2 changes: 1 addition & 1 deletion tests/testthat/test-observers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_that(".create_observers works", {
test_that("observers", {

input <- new.env()
rObjects <- new.env()
Expand Down
14 changes: 13 additions & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ test_that("utils", {
tse <- Tengeler2020

expect_equal(.import_datasets(c(1, 3)), c("GlobalPatterns", "Tengeler2020"))

expect_no_error(
tse <- .update_tse(transformAssay, list(x = tse, assay.type = "counts",
method = "relabundance"))
)

expect_true(.check_formula("data ~ patient_status + cohort", tse))
expect_false(.check_formula("data ~ wrong_var + sample_name", tse))

expect_length(.check_panel(tse, c(RowDataTable()), "RowDataTable", rowData), 1)
panels <- c(RowDataTable(), ReducedDimensionPlot())

expect_warning(
expect_length(
.check_panel(tse, panels, "ReducedDimensionPlot", reducedDims), 1
)
)

})

0 comments on commit f2e05cb

Please sign in to comment.