-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit tests to increase coverage
- Loading branch information
1 parent
81e6d18
commit c26341e
Showing
2 changed files
with
56 additions
and
2 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
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,41 @@ | ||
|
||
base_plot <- ggplot(mtcars, aes(x = mpg, y = wt)) + | ||
geom_point() | ||
|
||
test_that("long title fails", { | ||
p <- base_plot + | ||
labs(title = "This is a really long title that should fail wrap_labs with an error because it flows onto more than two lines, so it should definitely fail blah blah blah") | ||
|
||
expect_error(wrap_labs(p, type = "fullslide")) | ||
|
||
p <- base_plot + | ||
labs(title = "Regular title", | ||
subtitle = "Extremely long subtitle that should fail wrap_labs with an error, it'll take up too many lines even for a monster chart etc etc etc etc lorem ipsum lorem ipsum") | ||
|
||
expect_error(wrap_labs(p, type = "fullslide")) | ||
|
||
}) | ||
|
||
|
||
test_that("two line title wraps", { | ||
|
||
p <- base_plot + | ||
labs(title = "This is a slightly long title that should wrap onto two lines but work blah blah blah") | ||
|
||
p <- wrap_labs(p, type = "fullslide") | ||
|
||
expect_true(grepl("\n", p$labels$title)) | ||
|
||
}) | ||
|
||
test_that("caption wraps onto two lines", { | ||
|
||
p <- base_plot + | ||
labs(caption = "Notes: notes go here. Source: source goes here.") | ||
|
||
p <- wrap_labs(p, type = "fullslide") | ||
|
||
expect_true(grepl("\n", p$labels$caption)) | ||
|
||
}) | ||
|