tests/testthat/test-do_DotPlot.R

if (isFALSE(dep_check[["do_DotPlot"]])){

  testthat::test_that("do_DotPlot: CRAN essentials", {

    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1")
    testthat::expect_type(p, "list")

  })

  testthat::test_that("do_DotPlot: PASS - one variable", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1")
    testthat::expect_type(p, "list")

    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.position = "right")
    testthat::expect_type(p, "list")
    
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.position = "top")
    testthat::expect_type(p, "list")
    
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.position = "none")
    testthat::expect_type(p, "list")
    
    
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.position = "none",
                            use_viridis = FALSE)
    testthat::expect_type(p, "list")
    
    
    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.position = "none",
                            use_viridis = FALSE)
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - plot grid", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            plot.grid = TRUE)
    testthat::expect_type(p, "list")

    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            plot.grid = FALSE)
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - use_viridis", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            use_viridis = TRUE)
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - one variable legend normal", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.type = "normal")
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - one variable legend colorbar", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            legend.type = "colorbar")
    testthat::expect_type(p, "list")
  })





  testthat::test_that("do_DotPlot: FAIL - wrong legend type", {
    testthat::skip_on_cran()


    testthat::expect_error(suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                                                features = "EPC1",
                                                                flip = TRUE,
                                                                legend.type = "wrong")}))

  })

  testthat::test_that("do_DotPlot: FAIL - wrong legend position", {
    testthat::skip_on_cran()


    testthat::expect_error(suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                                                features = "EPC1",
                                                                flip = TRUE,
                                                                legend.position = "wrong")}))

  })

  testthat::test_that("do_DotPlot: FAIL - wrong font.type", {
    testthat::skip_on_cran()


    testthat::expect_error(suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                                                features = "EPC1",
                                                                flip = TRUE,
                                                                font.type = "wrong")}))

  })

  testthat::test_that("do_DotPlot: PASS - one variable flip", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            flip = TRUE)
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - multiple features", {
    testthat::skip_on_cran()
    
    genes <- Seurat::VariableFeatures(sample)[1:10]

    p <- suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                              features = genes)})
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - multiple features flip", {
    testthat::skip_on_cran()


    genes <- Seurat::VariableFeatures(sample)[1:10]
    
    p <- suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                              features = genes,
                                              flip = TRUE)})
    testthat::expect_type(p, "list")
  })

  testthat::test_that("do_DotPlot: PASS - multiple features flip rotate x labels", {
    testthat::skip_on_cran()


    genes <- Seurat::VariableFeatures(sample)[1:10]
    p <- suppressWarnings({SCpubr::do_DotPlot(sample = sample,
                                              features = genes,
                                              flip = TRUE,
                                              axis.text.x.angle = 45)})
    testthat::expect_type(p, "list")
  })





  testthat::test_that("do_DotPlot: PASS - one variable xlab, ylab, title, subtitle, caption", {
    testthat::skip_on_cran()


    p <- SCpubr::do_DotPlot(sample = sample,
                            features = "EPC1",
                            xlab = "A",
                            ylab = "B",
                            plot.title = "C",
                            plot.subtitle = "D",
                            plot.caption = "E")
    testthat::expect_type(p, "list")
  })
}
enblacar/SCpubr documentation built on Aug. 25, 2024, 9:45 p.m.