-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adaf6be
commit 46a7d75
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
|
||
exper <- demo_joy() |> | ||
mediation_data("PHQ", "treatment", starts_with("ASV")) | ||
ie <- multimedia(exper) |> | ||
estimate(exper) |> | ||
indirect_pathwise() |> | ||
effect_summary() | ||
|
||
test_that("Plot mediators returns on standard pathwise output.", { | ||
g <- plot_mediators(ie, exper) | ||
expect_s3_class(g, "patchwork") | ||
}) | ||
|
||
test_that("Can customize number of digits in plot_mediators output.", { | ||
g <- plot_mediators(ie, exper, n_digit = 1) | ||
expect_s3_class(g, "patchwork") | ||
g <- plot_mediators(ie, exper, n_digit = 3) | ||
expect_s3_class(g, "patchwork") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
test_that("ANSI handler converts R code to HTML tagged version", { | ||
output <- ansi_aware_handler("test") | ||
expect_equal(output, "<pre class=\"r-output\"><code>test</code></pre>") | ||
}) | ||
|
||
test_that("Show methods give expected output for mediation data object.", { | ||
exper <- mediation_data(demo_joy(), "PHQ", "treatment", starts_with("ASV")) | ||
expect_output(print(exper), "\\[Mediation Data\\]") | ||
expect_output(print(exper), "100 samples with measurements for,") | ||
}) | ||
|
||
test_that("vec_sub correctly truncates long outputs", { | ||
expect_equal(multimedia:::vec_sub(LETTERS[1:10]), "A, B, ...") | ||
expect_equal(multimedia:::vec_sub(1:10), "1, 2, ...") | ||
}) | ||
|
||
test_that("Show methods give expected output for a fitted multimedia object.", { | ||
exper <- mediation_data(demo_joy(), "PHQ", "treatment", starts_with("ASV")) | ||
model <- multimedia(exper) |> | ||
estimate(exper) | ||
expect_output(print(model), "\\[Multimedia Analysis\\]") | ||
expect_output(print(model), "Treatments: treatment") | ||
expect_output(print(model), "Mediators: ASV1, ASV2, ...") | ||
expect_output(print(model), "\\[Models\\]") | ||
expect_output(print(model), "mediation: A fitted") | ||
expect_output(print(model), "outcome: A fitted") | ||
}) |