tests/testthat/test-sampleData.R

test_that("Clean mode", {
    x <- sampleData(object, clean = TRUE)
    ## Require that all clean columns are factor.
    invisible(lapply(x, function(x) {
        expect_s3_class(x, "factor")
    }))
})

test_that("Verbose mode", {
    x <- sampleData(object, clean = FALSE)
    ## Return `interestingGroups` factor column by default.
    expect_s3_class(x[["interestingGroups"]], "factor")
    ## Otherwise it should be identical to `colData`.
    x[["interestingGroups"]] <- NULL
    expect_identical(
        object = as.data.frame(x),
        expected = as.data.frame(camelCase(colData(object), strict = TRUE))
    )
})

test_that("sampleData<-", {
    sampleData(object)[["testthat"]] <- factor("XXX")
    expect_identical(
        object = levels(sampleData(object)[["testthat"]]),
        expected = "XXX"
    )
})
hbc/bcbioRnaseq documentation built on April 1, 2024, 11:31 a.m.