Skip to content

Commit

Permalink
refactor: combine test files and reformat styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Spinner committed Jan 9, 2025
1 parent 93c0a53 commit 91ff80e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 40 deletions.
8 changes: 3 additions & 5 deletions inst/shiny/modules/column_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
#' @examples
#' column_mapping_widget(ns = NS("example"), id = "STUDYID",
#' tooltip_text = "Select the study identifier column.")
#'
#' @export
column_mapping_widget <- function(ns, id, tooltip_text) {
.column_mapping_widget <- function(ns, id, tooltip_text) {
div(
class = "column-mapping-row",
tooltip(
Expand All @@ -28,11 +26,11 @@ column_mapping_widget <- function(ns, id, tooltip_text) {
),
div(
class = "column-mapping-output",
span(paste0(id, ":"), style = "color: black; font-size: normal;")
span(paste0(id, ":"))
),
div(
class = "column-mapping-label",
span(textOutput(ns(paste0("label_", id))), style = "color: grey;")
span(textOutput(ns(paste0("label_", id))))
)
)
}
Expand Down
8 changes: 2 additions & 6 deletions inst/shiny/www/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@
}

.column-mapping-output {
margin-left: 0.625rem;
margin-top: 1.25rem;
margin-bottom: 0;
margin: 1.25rem 0 0 0.625rem;
color: black;
}

.column-mapping-label {
margin-left: 0.625rem;
margin-top: 1.25rem;
margin-bottom: 0;
margin: 1.25rem 0 0 0.625rem;
color: grey;
}

Expand Down
34 changes: 22 additions & 12 deletions tests/testthat/test-apply_labels.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
LABELS <- data.frame(
Variable = c("USUBJID", "AVAL"),
Label = c("Unique Subject Identifier", "Analysis Value"),
Dataset = c("ADPC", "ADPC")
)

describe("apply_labels", {
it("applies labels to matching data", {
data <- data.frame(
USUBJID = c(1, 2, 3),
AVAL = c(4, 5, 6)
)
labels <- data.frame(
Variable = c("USUBJID", "AVAL"),
Label = c("Unique Subject Identifier", "Analysis Value"),
Dataset = c("ADPC", "ADPC")
)
data <- apply_labels(data, labels, "ADPC")

data <- apply_labels(data, LABELS, "ADPC")
expect_equal(attr(data$USUBJID, "label"), "Unique Subject Identifier")
expect_equal(attr(data$AVAL, "label"), "Analysis Value")

Expand All @@ -19,13 +21,21 @@ describe("apply_labels", {
COL1 = c(1, 2, 3),
COL2 = c(4, 5, 6)
)
labels <- data.frame(
Variable = c("USUBJID", "AVAL"),
Label = c("Unique Subject Identifier", "Analysis Value"),
Dataset = c("ADPC", "ADPC")
)
data <- apply_labels(data, labels, "ADPC")

data <- apply_labels(data, LABELS, "ADPC")
expect_equal(attr(data$COL1, "label"), "COL1")
expect_equal(attr(data$COL2, "label"), "COL2")
})
})

describe("get_label", {
it("gets correct label from LABELs dataframe", {

get_label(LABELS, "USUBJID", "ADPC")
get_label(LABELS, "HEIGHT", "ADPC")

expect_equal(get_label(LABELS, "USUBJID", "ADPC"), "Unique Subject Identifier")
expect_equal(get_label(LABELS, "HEIGHT", "ADPC"), "No label available")

})
})
17 changes: 0 additions & 17 deletions tests/testthat/test-get_label.R
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
LABELS <- data.frame(
Variable = c("USUBJID", "AVAL"),
Label = c("Unique Subject Identifier", "Analysis Value"),
Dataset = c("ADPC", "ADPC")
)

describe("get_label", {
it("gets correct label from LABELs dataframe", {

get_label(LABELS, "USUBJID", "ADPC")
get_label(LABELS, "HEIGHT", "ADPC")

expect_equal(get_label(LABELS, "USUBJID", "ADPC"), "Unique Subject Identifier")
expect_equal(get_label(LABELS, "HEIGHT", "ADPC"), "No label available")

})
})

0 comments on commit 91ff80e

Please sign in to comment.