Skip to content

Commit c1e275d

Browse files
committed
Add tests
1 parent 9ea0de9 commit c1e275d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/testthat/test-base-model.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,34 @@ test_that("strict args order", {
158158
# Assert
159159
expect_equal(res, list(a = 4L, b = 2L))
160160
})
161+
162+
# ---
163+
test_that("discard extra fields", {
164+
# # Prepare
165+
my_model <- base_model(
166+
cyl = is.double,
167+
mpg = is.double
168+
)
169+
170+
# Act
171+
res <- my_model(mtcars)
172+
173+
# Assert
174+
expect_equal(ncol(res), 2)
175+
})
176+
177+
# ---
178+
test_that("allow extra fields", {
179+
# # Prepare
180+
my_model <- base_model(
181+
cyl = is.double,
182+
mpg = is.double,
183+
.model_config = model_config(extra = "allow")
184+
)
185+
186+
# Act
187+
res <- my_model(mtcars)
188+
189+
# Assert
190+
expect_equal(ncol(res), 11)
191+
})

0 commit comments

Comments
 (0)