Skip to content

Commit 9b84438

Browse files
committed
Add first testthat testing files
1 parent 19ee206 commit 9b84438

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/testthat/test-gt_object.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
context("test-gt_object.R")
2+
3+
test_that("an HTML table object contains the correct components", {
4+
5+
# Create an HTML table object with `gt()`
6+
# and the `iris` dataset
7+
table_object <-
8+
iris %>% gt()
9+
10+
# Expect that the list object has 5 components
11+
expect_equal(
12+
length(table_object), 5)
13+
14+
# Expect certain named components
15+
expect_equal(
16+
table_object %>% names(),
17+
c("source_tbl", "heading", "footnote", "source_note", "html_table"))
18+
})

tests/testthat/test-quick_table.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
context("test-quick_table.R")
2+
3+
test_that("the creation of a quick table works", {
4+
5+
# Quickly create an html table using the
6+
# `quick_table()` with the iris dataset
7+
html <- quick_table(iris)
8+
9+
# Expect that the object returned has the
10+
# `knit_asis` class
11+
expect_is(html, "knit_asis")
12+
13+
# Expect that the object returned is the
14+
# type of `character`
15+
expect_type(html, "character")
16+
})

0 commit comments

Comments
 (0)