Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ldecicco-USGS committed Aug 16, 2016
1 parent 272cede commit bbfc10f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion inst/extdata/lineScatter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ lines:
col: "black"
lty: 1
lwd: 1
labels: FALSE
abline:
col: "grey"
lty: 1
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/tests-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,27 @@ test_that("formals are correctly retrieved", {
test_that("non-existant type hits error", {
expect_error(config("foo"))
})

test_that("config temp", {
df <- data.frame(x = 1:10, y=1:10, z = seq(2,20,2))

gsp <- gsplot(config.file = system.file("extdata", "lineScatter.yaml", package = "gsplot")) %>%
lines(df$x, df$y, col="red", legend.name = "points")
expect_true(gsp$global$config$config.file)

gspDef <- gsplot() %>%
lines(df$x, df$y, col="red", legend.name = "points")
expect_false(gspDef$global$config$config.file)

loadConfig(system.file("extdata", "lineScatter.yaml", package = "gsplot"))
gsp <- gsplot() %>%
lines(df$x, df$y, col="red", legend.name = "points")
expect_false(gsp$global$config$config.file)
expect_equal(gsp$side.1$axis$lwd, 0.8)

loadConfig()
gspDef2 <- gsplot() %>%
lines(df$x, df$y, col="red", legend.name = "points")
expect_false(gspDef2$global$config$config.file)
expect_null(gspDef2$side.1$axis$lwd)
})

0 comments on commit bbfc10f

Please sign in to comment.