Skip to content

Commit

Permalink
fix: adjusts tests to new output
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Sep 11, 2023
1 parent 47a873c commit 8ed01b1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
30 changes: 28 additions & 2 deletions tests/testthat/_snaps/assaySpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,34 @@
<div class="form-group shiny-input-container">
<label class="control-label" id="my_assay-name-label" for="my_assay-name">Please select the best assay</label>
<div>
<select id="my_assay-name"><option value="" selected></option></select>
<script type="application/json" data-for="my_assay-name">{"plugins":["selectize-plugin-a11y"]}</script>
<select class="shiny-input-select form-control" id="my_assay-name"></select>
<script type="application/json" data-for="my_assay-name">{"placeholder":"- Nothing selected -","plugins":["selectize-plugin-a11y"]}</script>
</div>
</div>
<script>// Toggle enable/disable of a dropdown
//
// This can be done by `{shinyjs::enable/disable}` R package if that package is
// added to the dependecies.
// Parameters
// `message` should have `input_id` string and `disabled` logical properties.
Shiny.addCustomMessageHandler('toggle_dropdown', function(message) {
const input_id = message.input_id;
const disabled = message.disabled;
let el = document.getElementById(input_id)
if (el.selectize !== undefined) {
el = el.selectize;
if (disabled) {
el.lock();
el.disable();
} else {
el.unlock();
el.enable();
}
} else {
// Fallback in case selectize is not enabled
el.disabled = disabled ? 'disabled' : '';
}
});</script>

14 changes: 13 additions & 1 deletion tests/testthat/test-adtteSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,19 @@ test_that("adtteSpecInput creates expected HTML", {
label_paramcd = "Select right PARAMCD"
))

expect_tag(result)
expect_class(result, "shiny.tag.list")
expect_length(result, 2)

# First element is a div tag
expect_tag(result[[1]])
expect_class(result[[1]], "shiny.tag")
expect_identical(result[[1]]$name, "div")

# Second element is the contents of a single js file
expect_length(result[[2]], 1)
expect_tag(result[[2]][[1]])
expect_class(result[[2]][[1]], "shiny.tag")
expect_identical(result[[2]][[1]]$name, "script")
})

# nolint start
Expand Down

0 comments on commit 8ed01b1

Please sign in to comment.