Skip to content

Commit 102876a

Browse files
committed
Can't count on the second axis to be in the second spot of the list.
1 parent 775c0e2 commit 102876a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/testthat/tests-date_axis.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test_that("two axis calls added to side 1", {
1010

1111
test_that("axis ticks in the right location", {
1212
gs <- gsplot() %>%
13-
points(seq(as.Date("2013-01-01"), as.Date("2013-12-31"), "days"), 1:31) %>%
13+
points(seq(as.Date("2013-01-01"), as.Date("2013-12-31"), "days"), 1:365) %>%
1414
date_axis(side=1, lab.pos = "interval", tick.int="month", "snap.to"="month")
1515

1616
ticks <- lazy_eval(gs$side.1$axis$at, data=list(object=gs))
@@ -24,7 +24,9 @@ test_that("axis labels centered on interval", {
2424
points(seq(as.Date("2013-01-01"), as.Date("2013-12-31"), "days"), 1:365) %>%
2525
date_axis(side=1, lab.pos = "interval", tick.int="month", "snap.to"="month")
2626

27-
labels <- lazyeval::lazy_eval(gs$side.1[[2]]$at, data=list(object=gs))
27+
second.axis <- gs$side.1
28+
which.axis <- which(names(second.axis)== 'axis')
29+
labels <- lazyeval::lazy_eval(gs$side.1[[which.axis[2]]]$at, data=list(object=gs))
2830
expect_true(all.equal(labels[1], as.Date("2013-01-15"), tolerance=0.01))
2931
expect_true(all.equal(labels[7], as.Date("2013-07-15"), tolerance=0.01))
3032
expect_true(all.equal(labels[12], as.Date("2013-12-15"), tolerance=0.01))
@@ -35,7 +37,10 @@ test_that("axis labels centered on ticks", {
3537
points(seq(as.Date("2013-01-01"), as.Date("2013-01-31"), "days"), 1:31) %>%
3638
date_axis(side=1, lab.pos = "tick", tick.int="day", "snap.to"="month")
3739

38-
labels <- lazy_eval(gs$side.1[[2]]$at, data=list(object=gs))
40+
second.axis <- gs$side.1
41+
which.axis <- which(names(second.axis)== 'axis')
42+
43+
labels <- lazy_eval(gs$side.1[[which.axis[2]]]$at, data=list(object=gs))
3944
expect_equal(labels[1], as.Date("2013-01-01"))
4045
expect_equal(labels[7], as.Date("2013-01-07"))
4146
expect_equal(labels[22], as.Date("2013-01-22"))

0 commit comments

Comments
 (0)