Skip to content

Commit

Permalink
fix(listGroupInput): shift dots arg to front
Browse files Browse the repository at this point in the history
  • Loading branch information
nteetor committed Mar 14, 2020
1 parent e1ed698 commit ce0fbbe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
12 changes: 6 additions & 6 deletions R/list-group.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
#' layout = "horizontal"
#' )
#'
listGroupInput <- function(id, choices = NULL, values = choices,
selected = NULL, ..., layout = "vertical",
listGroupInput <- function(..., id, choices = NULL, values = choices,
selected = NULL, layout = "vertical",
flush = FALSE) {
assert_id()
assert_choices()
assert_possible(layout, c("vertical", "horizontal"))
assert_possible(flush, c(TRUE, FALSE))

tag <- dep_attach({
with_deps({
layout <- resp_construct(layout, c("vertical", "horizontal"))
classes <- resp_classes(layout, "list-group")

Expand All @@ -124,7 +124,7 @@ listGroupInput <- function(id, choices = NULL, values = choices,

items <- map_listitems(choices, values, selected)

tags$div(
tag <- div(
class = str_collate(
"yonder-list-group",
"list-group",
Expand All @@ -135,9 +135,9 @@ listGroupInput <- function(id, choices = NULL, values = choices,
items,
...
)
})

s3_class_add(tag, c("yonder_list_group", "yonder_input"))
s3_class_add(tag, c("yonder_list_group", "yonder_input"))
})
}

#' @rdname listGroupInput
Expand Down
10 changes: 5 additions & 5 deletions man/listGroupInput.Rd

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

24 changes: 15 additions & 9 deletions tests/testthat/test-list-group.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
context("list group input")

test_that("id is character or null", {
expect_silent(listGroupInput("ID"))
expect_silent(listGroupInput(NULL))
expect_silent(listGroupInput(id = "ID"))
expect_silent(listGroupInput(id = NULL))

expect_error(listGroupInput(NA_character_))
expect_error(listGroupInput(3030))
expect_error(listGroupInput(id = NA_character_))
expect_error(listGroupInput(id = 3030))
})

test_that("choices and values same length", {
expect_silent(listGroupInput("ID", c("one")))
expect_silent(listGroupInput("ID", c("two"), c("two")))
expect_silent(listGroupInput(id = "ID", choices = c("one")))
expect_silent(listGroupInput(
id = "ID", choices = c("two"), values = c("two")
))

expect_error(listGroupInput("ID", c("three"), c("three", "four")))
expect_error(listGroupInput("ID", c("four", "five"), "four"))
expect_error(listGroupInput(
id = "ID", choices = c("three"), values = c("three", "four")
))
expect_error(listGroupInput(
id = "ID", choices = c("four", "five"), values = "four"
))
})

test_that("has dependencies", {
expect_dependencies(listGroupInput("ID"))
expect_dependencies(listGroupInput(id = "ID"))
})

0 comments on commit ce0fbbe

Please sign in to comment.