-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add-test-to-animint2 #176
base: master
Are you sure you want to change the base?
add-test-to-animint2 #176
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library("testthat") | ||
library("animint2") | ||
library("RSelenium") | ||
library("XML") | ||
source("helper-functions.R") | ||
source("helper-HTML.R") | ||
source("helper-plot-data.r") | ||
|
||
tests_init() | ||
tests_run(filter="renderer3-TestWorldBankTwoLayers") | ||
tests_exit() | ||
|
||
tests_init("firefox") | ||
tests_run(filter="renderer3-TestWorldBankTwoLayers") | ||
tests_exit() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
acontext("TestWorldBankTwoLayers") | ||
|
||
data(WorldBank, package="animint2") | ||
|
||
# Filter the data for specific years | ||
WorldBank1975 <- subset(WorldBank, year == 1975) | ||
WorldBankBefore1975 <- subset(WorldBank, 1970 <= year & year <= 1975) | ||
|
||
# Define income levels and colors | ||
income.colors <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33") | ||
WorldBank$income <- factor(WorldBank$income, | ||
levels = c("High income: nonOECD", "High income: OECD", | ||
"Upper middle income", "Lower middle income", | ||
"Low income", "Not classified")) | ||
names(income.colors) <- levels(WorldBank$income) | ||
|
||
# Create the scatter plot with one layer | ||
scatter <- ggplot() + | ||
scale_color_manual(values = income.colors) + | ||
geom_point( | ||
mapping = aes(x = life.expectancy, y = fertility.rate, color = income), | ||
data = WorldBank1975 | ||
) | ||
|
||
# Add the second layer for paths | ||
two.layers <- scatter + | ||
geom_path( | ||
aes( | ||
x = life.expectancy, | ||
y = fertility.rate, | ||
color = income, | ||
group = country | ||
), | ||
data = WorldBankBefore1975 | ||
) | ||
|
||
# Create an interactive plot | ||
scatter_plot <- list(plot = two.layers) | ||
animint(scatter_plot) | ||
|
||
# Test that the visualization generates without warnings or errors | ||
test_that("worldbank two-layers visualization generated without any warnings or errors", { | ||
expect_no_warning({ | ||
info <- animint2HTML(scatter_plot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test does not use the renderer. please show that you understand how to inspect the output of the chromote renderer, and simulate interaction.
also this world bank data viz is not a very interesting test case, because you have no clickSelects/showSelected here. Instead can you write a test based on the animation example you created? https://busttech.github.io/deploy2/ |
||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove mytests.r file