Skip to content

Commit

Permalink
Add test file with a doppelganger-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Knecht authored and Thomas Knecht committed Sep 17, 2019
1 parent a681f59 commit e2c1fb6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/testthat/test-position-nudgestack.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
context("position_nudgestack")

test_that("position_nudgestack draws correctly", {
ESM <- data_frame(
DAX = EuStockMarkets[colnames(EuStockMarkets) == "DAX"],
SMI = EuStockMarkets[colnames(EuStockMarkets) == "SMI"],
CAC = EuStockMarkets[colnames(EuStockMarkets) == "CAC"],
FTSE = EuStockMarkets[colnames(EuStockMarkets) == "FTSE"],
date = as.Date(paste(1, zoo::as.yearmon(time(EuStockMarkets))),
format = "%d %b %Y"
)
)

ESM_prep <- ESM %>%
tidyr::gather(key = key, value = value, -date) %>%
group_by(date, key) %>%
summarize(value = mean(value)) %>%
filter(date >= "1995-01-01" & date < "1998-01-01")

stock_marked <- ggplot(data = ESM_prep, mapping = aes(x = date, y = value, fill = key)) +
geom_col(position = position_nudgestack(x = 15))

expect_doppelganger(
"nudgestack EuStockMarkets data",
stock_marked
)
})

0 comments on commit e2c1fb6

Please sign in to comment.