Skip to content

Commit 69ae934

Browse files
committed
use is_theme()
1 parent c8a0683 commit 69ae934

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

R/theme.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,12 @@ is.theme <- function(x) {
584584

585585
# check whether theme is complete
586586
is_theme_complete <- function(x) {
587-
is.theme(x) && isTRUE(x@complete)
587+
is_theme(x) && isTRUE(x@complete)
588588
}
589589

590590
# check whether theme should be validated
591591
is_theme_validate <- function(x) {
592-
!is.theme(x) || isTRUE(x@validate)
592+
!is_theme(x) || isTRUE(x@validate)
593593
}
594594

595595
check_theme <- function(theme, tree = get_element_tree(), call = caller_env()) {
@@ -703,7 +703,7 @@ add_theme <- function(t1, t2, t2name, call = caller_env()) {
703703
}
704704
)
705705

706-
if (!is.theme(t1) && is.list(t1)) {
706+
if (!is_theme(t1) && is.list(t1)) {
707707
t1 <- theme(!!!t1)
708708
}
709709

tests/testthat/_snaps/4.5/theme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# modifying theme element properties with + operator works
2+
3+
Code
4+
theme_grey() + "asdf"
5+
Condition
6+
Error:
7+
! Can't add `"asdf"` to a theme object.
8+

tests/testthat/test-theme.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test_that("modifying theme element properties with + operator works", {
1919
t <- theme_grey() + theme(axis.title.x = element_text(colour = 'red', margin = margin()))
2020
expect_identical(t$axis.title.x, element_text(colour = 'red', margin = margin(), vjust = 1))
2121
# Make sure the theme class didn't change or get dropped
22-
expect_s3_class(t, "theme")
22+
expect_s7_class(t, class_theme)
2323
# Make sure the element class didn't change or get dropped
2424
expect_s3_class(t$axis.title.x, "element")
2525
expect_s3_class(t$axis.title.x, "element_text")
@@ -107,7 +107,7 @@ test_that("replacing theme elements with %+replace% operator works", {
107107
t <- theme_grey() %+replace% theme(axis.title.x = element_text(colour = 'red'))
108108
expect_identical(t$axis.title.x, element_text(colour = 'red'))
109109
# Make sure the class didn't change or get dropped
110-
expect_s3_class(t, "theme")
110+
expect_s7_class(t, class_theme)
111111

112112
# Changing an intermediate node works
113113
t <- theme_grey() %+replace% theme(axis.title = element_text(colour = 'red'))

0 commit comments

Comments
 (0)