test_that("rob_tools() returns all 14 expected tools", { nms <- rob_tools() expect_true(all(c( "ROB2", "ROB2-Cluster", "ROBINS-I", "ROBINS-E", "QUADAS-2", "QUADAS-C", "QUIPS", "ROBIS", "PROBAST", "NOS-Cohort", "NOS-CaseControl", "NOS-CrossSectional", "GRADE", "Generic" ) %in% nms)) }) test_that(".standardise_judgement handles case, whitespace, abbreviations", { expect_equal(.standardise_judgement("low"), "Low") expect_equal(.standardise_judgement("HIGH"), "High") expect_equal(.standardise_judgement("some concern"), "Some concerns") expect_equal(.standardise_judgement("ni"), "No information") expect_equal(.standardise_judgement("NI"), "No information") expect_equal(.standardise_judgement(" Low "), "Low") expect_equal(.standardise_judgement("serious"), "Serious") expect_equal(.standardise_judgement("critical"), "Critical") expect_equal(.standardise_judgement("very low"), "Very low") }) test_that(".resolve_colours returns named vector for cochrane palette", { cols <- .resolve_colours("cochrane", c("Low", "High", "No information")) expect_named(cols) expect_true("Low" %in% names(cols)) expect_true("High" %in% names(cols)) # NI always gets grey expect_true("No information" %in% names(cols)) expect_match(cols[["No information"]], "^#[0-9A-Fa-f]{6}$") }) test_that(".resolve_colours works for colourblind palette", { cols <- .resolve_colours("colourblind", c("Low", "Some concerns", "High")) expect_named(cols) expect_equal(length(cols), 3) }) test_that(".resolve_colours accepts user hex vector", { cols <- .resolve_colours(c("#aabbcc", "#ddee00"), c("Low", "High")) expect_equal(cols[["Low"]], "#aabbcc") expect_equal(cols[["High"]], "#ddee00") }) test_that(".resolve_colours errors on mismatched user vector", { expect_error( .resolve_colours(c("#aabbcc"), c("Low", "High")), "Colour vector length mismatch" ) }) test_that(".validate_data errors on unknown tool", { df <- data.frame(Study = "S1", D1 = "Low") expect_error(.validate_data(df, "NOTREAL"), "Unknown tool") }) test_that(".validate_data errors on empty data", { df <- data.frame(Study = character(0)) expect_error(.validate_data(df, "ROB2"), "non-empty data frame") }) test_that("ROBINS-I has correct post-Nov-2024 domain order", { tmpl <- .rv_tools[["ROBINS-I"]] expect_equal(tmpl$domains[2], "D2: Selection of participants") expect_equal(tmpl$domains[3], "D3: Classification of interventions") }) test_that("QUADAS-2 has applicability_domains field", { tmpl <- .rv_tools[["QUADAS-2"]] expect_true(!is.null(tmpl$applicability_domains)) expect_equal(length(tmpl$applicability_domains), 3L) }) test_that("NOS tools are score_based = TRUE", { for (t in c("NOS-Cohort", "NOS-CaseControl", "NOS-CrossSectional")) { expect_true(.rv_tools[[t]]$score_based, label = paste(t, "score_based")) expect_equal(.rv_tools[[t]]$max_total, 9L) } })