Skip to content

Commit

Permalink
Test to check for title of 3 plots
Browse files Browse the repository at this point in the history
Test to check for titles of 3 plots
  • Loading branch information
siddhesh195 committed Jul 10, 2024
1 parent be99e45 commit e5a6803
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/testthat/test-renderer3-threeplots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@


test_that("check if two plots exist", {
data1 <- data.frame(
x = c(1, 2, 3), # x-coordinates of the dots
y = c(1, 4, 9) # y-coordinates of the dots
)

plot1 <- ggplot(data1, aes(x, y)) +
geom_point(size = 2) + # Plot points with a specified size
ggtitle("Plot of 3 Dots") + # Add a title to the plot
xlab("X Axis") + ylab("Y Axis")

data2 <- data.frame(
x = c(1, 2), # x-coordinates of the dots
y = c(1, 4) # y-coordinates of the dots
)

plot2 <- ggplot(data2, aes(x, y)) +
geom_point(size = 2) + # Plot points with a specified size
ggtitle("Plot of 2 Dots") + # Add a title to the plot
xlab("X Axis") + ylab("Y Axis")

data3 <- data.frame(
x = c(2), # x-coordinates of the dots
y = c(2) # y-coordinates of the dots
)

plot3 <- ggplot(data3, aes(x, y)) +
geom_point(size = 2) + # Plot points with a specified size
ggtitle("Plot of 1 Dot") + # Add a title to the plot
xlab("X Axis") + ylab("Y Axis")

plot_list <- list(
plot1 = plot1,
plot2=plot2,
plot3=plot3
)

info <-animint2HTML(plot_list)
titles <- getNodeSet(info$html, "//text[@class='plottitle']")
expect_match(xmlValue(titles[[1]]), "Plot of 3 Dots")
expect_match(xmlValue(titles[[2]]), "Plot of 2 Dots")
expect_match(xmlValue(titles[[3]]), "Plot of 1 Dot")
})

0 comments on commit e5a6803

Please sign in to comment.