test_that("The parameter must be a data frame", { expect_error( dropEmpty(dataframe = 1) ) }) test_that("A dataframe must be returned", { dataframe_ <- head(iris, 10) # The Species column is going to be dropped. dataframe_$Species <- NA dataframeWithoutSpecies_ <- dropEmpty(dataframe = dataframe_) # The first row is going to be dropped. dataframe_[1, ] <- NA dataframeWithoutFirstRow_ <- dropEmpty(dataframe = dataframe_) expect_true(is.data.frame(dataframeWithoutSpecies_)) expect_true(is.data.frame(dataframeWithoutFirstRow_)) }) test_that("Drops a column", { dataframe_ <- head(iris, 10) # The Species column is going to be dropped. dataframe_$Species <- NA dataframeWithoutSpecies_ <- dropEmpty(dataframe_) numberOfColumns_ <- ncol(dataframeWithoutSpecies_) expect_equal(numberOfColumns_, 4) }) test_that("Drops a row", { dataframe_ <- head(iris, 10) # The first row is going to be dropped. dataframe_[1, ] <- NA dataframeWithoutFirstRow_ <- dropEmpty(dataframe = dataframe_) numberOfRows_ <- nrow(dataframeWithoutFirstRow_) expect_equal(numberOfRows_, 9) })