Skip to content

Commit

Permalink
more tests for panel
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Mar 22, 2024
1 parent 49701d3 commit f324abf
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion R/f7Panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ f7PanelMenu <- function(..., id = NULL) {
}

shiny::tags$div(
class = "list links-list",
class = "list links-list list-dividers",
shiny::tags$ul(
class = "panel-menu ",
...,
Expand Down
17 changes: 2 additions & 15 deletions man/panel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"input": {
"comfirm_dialog": true,
"prompt_dialog": ""
"prompt_dialog": "test"
}
}
Binary file modified tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"user": "",
"password": "test"
},
"prompt_dialog": ""
"prompt_dialog": "test"
}
}
Binary file modified tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions tests/testthat/test-f7Panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,40 @@ test_that("panel works", {
app$wait_for_idle(1000)
app$expect_values(input = inputs)
})

test_that("panel tag works", {
id <- "test"
panel <- f7Panel(id = id)
expect_s3_class(panel, "shiny.tag")

# structure
expect_identical(panel$attribs$class, "panel panel-left panel-reveal")
expect_length(panel$children, 2)
expect_identical(panel$children[[1]]$attribs$`data-for`, id)
expect_identical(panel$children[[2]]$attribs$class, "page")

# Config
config <- jsonlite::fromJSON(panel$children[[1]]$children[[1]])
expect_length(config, 1)
expect_identical(config[["effect"]], "reveal")
})

test_that("panel menu works", {
panel_menu <- f7PanelMenu(id = "menu")
expect_s3_class(panel_menu, "shiny.tag")

# structure
expect_identical(panel_menu$attribs$class, "list links-list list-dividers")
expect_identical(panel_menu$children[[1]]$attribs$id, "menu")
})

test_that("panel item works", {
panel_item <- f7PanelItem("Title", "tab1", active = TRUE)
expect_s3_class(panel_item, "shiny.tag")
expect_identical(panel_item$name, "li")
expect_identical(panel_item$children[[1]]$attribs$`data-tab`, "#tab1")
expect_identical(
panel_item$children[[1]]$attribs$class,
"tab-link tab-link-active"
)
})

0 comments on commit f324abf

Please sign in to comment.