From 43014341ba9d80820896415d6adab39528091091 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Mar 2024 18:17:01 +0100 Subject: [PATCH] increase test coverage --- tests/testthat/_snaps/data_peek.md | 19 +++++++++++++++++++ tests/testthat/test-data_peek.R | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/tests/testthat/_snaps/data_peek.md b/tests/testthat/_snaps/data_peek.md index 91475eac5..350106368 100644 --- a/tests/testthat/_snaps/data_peek.md +++ b/tests/testthat/_snaps/data_peek.md @@ -41,3 +41,22 @@ Petal.Width | numeric | 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, ... Species | factor | setosa, setosa, setosa, setosa, setosa, setosa, setosa, setosa, setosa, setosa, setosa, setosa, ... +# data_peek, print_md works as expected + + Code + print_md(out) + Output + [1] "Table: Data frame with 150 rows and 5 variables" + [2] "" + [3] "|Variable | Type | Values |" + [4] "|:------------|:-------|:----------------------------------------------|" + [5] "|Sepal.Length |numeric | 5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 5, 4.4, ... |" + [6] "|Sepal.Width |numeric |3.5, 3, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, ... |" + [7] "|Petal.Length |numeric | 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, ... |" + [8] "|Petal.Width |numeric | 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, ... |" + [9] "|Species | factor | setosa, setosa, setosa, setosa, setosa, ... |" + attr(,"format") + [1] "pipe" + attr(,"class") + [1] "knitr_kable" "character" + diff --git a/tests/testthat/test-data_peek.R b/tests/testthat/test-data_peek.R index e16e772bd..85896a855 100644 --- a/tests/testthat/test-data_peek.R +++ b/tests/testthat/test-data_peek.R @@ -33,3 +33,9 @@ test_that("data_peek snapshots look as expected", { expect_snapshot(data_peek(iris, select = 1:3)) expect_snapshot(data_peek(iris, width = 130)) }) + + +test_that("data_peek, print_md works as expected", { + out <- data_peek(iris) + expect_snapshot(print_md(out)) +})