Skip to content

Commit 364bcce

Browse files
committed
add manual tests
1 parent a566897 commit 364bcce

File tree

8 files changed

+118
-1
lines changed

8 files changed

+118
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: shinycssloaders
22
Title: Add Loading Animations to a 'shiny' Output While It's Recalculating
3-
Version: 1.1.0.9005
3+
Version: 1.1.0.9006
44
Authors@R: c(
55
person("Dean","Attali",email="[email protected]",role=c("aut","cre"),
66
comment = c("Maintainer/developer of shinycssloaders since 2019", ORCID="0000-0002-5645-3493")),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Add `fill` argument to support {bslib} cards and fillable containers (#76)
66
- Add `inline` argument to allow displaying spinner inline (#25)
77
- Add `width` argument that can be used in rare cases where the spinner has no inherent width (#85)
8+
- Added manual tests for most of the supported features
89

910
# shinycssloaders 1.1.0 (2024-07-30)
1011

tests/manual/1-basic.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
library(shiny)
2+
3+
shinyApp(
4+
ui = fluidPage(
5+
actionButton("go", "Go"),
6+
withSpinner(plotOutput("plot"))
7+
),
8+
server = function(input, output) {
9+
output$plot <- renderPlot({
10+
input$go
11+
Sys.sleep(1.5)
12+
plot(runif(10))
13+
})
14+
}
15+
)

tests/manual/2-params.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library(shiny)
2+
3+
shinyApp(
4+
ui = fluidPage(
5+
actionButton("go", "Go"),
6+
withSpinner(plotOutput("plot"), type = 2, color = "darkblue", size = 2,
7+
color.background = "blue", caption = "Test", delay = 300)
8+
),
9+
server = function(input, output) {
10+
output$plot <- renderPlot({
11+
input$go
12+
Sys.sleep(1.5)
13+
plot(runif(10))
14+
})
15+
}
16+
)

tests/manual/3-proxy-inline.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library(shiny)
2+
3+
shinyApp(
4+
ui = fluidPage(
5+
actionButton("go", "Go"),
6+
withSpinner(textOutput("text"), proxy.height = 80, inline = TRUE, width = 300),
7+
"Test"
8+
),
9+
server = function(input, output) {
10+
output$text <- renderText({
11+
input$go
12+
Sys.sleep(1.5)
13+
toString(sample(LETTERS, 3))
14+
})
15+
}
16+
)

tests/manual/4-show-hide.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
library(shiny)
2+
3+
ui <- fluidPage(
4+
shinyjs::useShinyjs(),
5+
actionButton("think","think"),
6+
actionButton("unthink","unthink"),
7+
actionButton("show","show"),
8+
actionButton("hide","hide"), br(), br(), br(),
9+
withSpinner(plotOutput("plot"))
10+
)
11+
12+
server <- function(input, output, session) {
13+
output$plot <- renderPlot({
14+
plot(runif(10))
15+
})
16+
observeEvent(input$think, showSpinner("plot"))
17+
observeEvent(input$unthink, hideSpinner("plot"))
18+
observeEvent(input$show, shinyjs::show("plot"))
19+
observeEvent(input$hide, shinyjs::hide("plot"))
20+
}
21+
22+
shinyApp(ui, server)

tests/manual/5-fill.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library(shiny)
2+
library(bslib)
3+
4+
ui <- page_fluid(
5+
layout_columns(
6+
card(
7+
full_screen = TRUE,
8+
card_header("without spinner"),
9+
card_body(plotOutput("plot1"))
10+
),
11+
card(
12+
full_screen = TRUE,
13+
card_header("with spinner"),
14+
card_body(withSpinner(plotOutput("plot2"), fill = TRUE))
15+
)
16+
),
17+
actionButton("go", "go")
18+
)
19+
20+
server <- function(input, output) {
21+
22+
output$plot1 <- output$plot2 <- renderPlot({
23+
input$go
24+
Sys.sleep(0.2)
25+
plot(runif(20))
26+
})
27+
28+
}
29+
30+
shinyApp(ui, server)

tests/manual/6-pageSpinner.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library(shiny)
2+
3+
ui <- fluidPage(
4+
actionButton("go", "Go"),
5+
plotOutput("plot")
6+
)
7+
server <- function(input, output) {
8+
observeEvent(input$go, {
9+
showPageSpinner()
10+
Sys.sleep(1)
11+
hidePageSpinner()
12+
})
13+
output$plot <- renderPlot({
14+
plot(runif(10))
15+
})
16+
}
17+
shinyApp(ui, server)

0 commit comments

Comments
 (0)