Skip to content

Commit c5efbaa

Browse files
committed
fix tests
1 parent 4180b88 commit c5efbaa

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

inst/htmljs/animint.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,17 +1098,18 @@ var animint = function (to_select, json_file) {
10981098

10991099
var colour = "black", colour_off;
11001100
var get_colour;
1101+
var get_colour_off = function (d) {
1102+
return colour_off;
1103+
};
11011104
if(aes.hasOwnProperty("colour")){
11021105
get_colour = get_attr("colour");
1106+
get_colour_off = get_colour;
11031107
}else{
11041108
get_colour = function (d) {
11051109
return colour;
11061110
};
11071111
}
11081112
var get_colour_off_default = get_colour;
1109-
var get_colour_off = function (d) {
1110-
return colour_off;
1111-
};
11121113

11131114
var fill = "black", fill_off = "black";
11141115
var get_fill = function (d) {

tests/testthat/test-renderer1-geom-text-color.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ library(animint2)
33
df <- data.frame(x=1,y="foo")
44
viz <- animint(
55
text=ggplot()+
6-
geom_text(aes(x, 4, label=y), color="black", clickSelects="y", data=df)+
6+
geom_text(aes(x, 4, label=y, id="ONETEXT"), color="black", clickSelects="y", data=df)+
77
geom_text(aes(x, 3, label=y, color=y), data=df)+
88
scale_color_manual(values=c(foo="blue"))+
99
geom_text(aes(x, 2, label=y), color="red", data=df)+
@@ -17,7 +17,7 @@ test_that("geom_text color rendered as fill style", {
1717
expect_identical(opacity, c("1","1","1","1"))
1818
})
1919

20-
clickID("plot_text_y_variable_foo_label")#not _svg.
20+
clickID("ONETEXT")
2121
after.html <- getHTML()
2222
test_that("geom_text color rendered as fill style", {
2323
fill <- getStyleValue(after.html, '//text[@class="geom"]', "fill")

tests/testthat/test-renderer2-colour.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ viz.point <- list(
9393
fill = disp),
9494
data = mtcars,
9595
colour="red",
96-
colour_off="transparent",
96+
colour_off="yellow",
9797
alpha_off=1,
9898
size = 10,
9999
clickSelects = "gear")+
@@ -122,7 +122,7 @@ test_that("setting alpha_off and colour_off makes only stroke change", {
122122
'//svg[@id="plot_acoff"]//circle[@class="geom"]',
123123
"stroke")
124124
stroke.tab <- sort(table(stroke.str))
125-
expect_color(names(stroke.tab), c("red","transparent"))
125+
expect_color(names(stroke.tab), c("red","yellow"))
126126
})
127127

128128
#

tests/testthat/test-renderer2-widerect.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
acontext("geom_widerect")
2-
2+
library(animint2)
33
expect_source <- function(expected){
44
a.list <- getNodeSet(info$html, '//a[@id="a_source_href"]')
55
computed <- if(length(a.list)==0){
@@ -8,7 +8,7 @@ expect_source <- function(expected){
88
at.mat <- sapply(a.list, xmlAttrs)
99
at.mat["href",]
1010
}
11-
expect_identical(computed, expected)
11+
expect_identical(as.character(computed), as.character(expected))
1212
}
1313

1414
recommendation <- data.frame(

tests/testthat/test-renderer3-ChromHMMinit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ test_that("animation starts by default", {
8787
test_that("default tile colour/stroke is transparent", {
8888
stroke.vec <- getStyleValue(
8989
info$html, '//g[@class="geom1_tile_parameters"]//rect', "stroke")
90-
expect_identical(stroke.vec, rep("black", 90))
90+
expect_color(stroke.vec, "black")
9191
})

0 commit comments

Comments
 (0)