Skip to content

Commit

Permalink
First example of tests. Add for non-plotting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
levisc8 committed Mar 29, 2018
1 parent 7b382e6 commit 87cf718
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
^html$
^\.RData
^appveyor\.yml$
^codecov\.yml$
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ License: MIT + file LICENSE
BugReports: https://github.com/valentinitnelav/plotbiomes/issues
Depends:
R (>= 3.1)
Imports:
Imports:
data.table (>= 1.10.4-3),
ggplot2 (>= 2.2.1),
mapview (>= 2.3.0),
sp (>= 1.2-7)
Suggests:
Suggests:
grImport,
sf,
knitr,
raster,
roxygen2,
plotly,
covr
covr,
testthat
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!-- CI badges -->
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/jag1bo7jaao5jid3/branch/develop?svg=true)](https://ci.appveyor.com/project/valentinitnelav/plotbiomes/branch/develop)
[![Travis Build Status](https://travis-ci.org/valentinitnelav/plotbiomes.svg?branch=develop)](https://travis-ci.org/valentinitnelav/plotbiomes)
[![Coverage Status](https://img.shields.io/codecov/c/github/valentinitnelav/plotbiomes/master.svg)](https://codecov.io/github/valentinitnelav/plotbiomes?branch=master)

<!--
Fixing errors from Travis CI can be time consuming ...
I gave up since the effort to fix the errors is not worth the time!
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(plotbiomes)

test_check("plotbiomes")
30 changes: 30 additions & 0 deletions tests/testthat/test-base_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# test whittaker_base_plot()
context('Whittaker base plot')

library(ggplot2)

test_plot <- whittaker_base_plot()



test_that('function and arguments work correctly', {

expect_true(inherits(test_plot, 'ggplot'))

# colors are named properly when not user specified
colors <- gray(0:9 / 9)

expect_message(whittaker_base_plot(color_palette = colors),
regexp = "Names for 'color_palette'")

tlc_legend <- whittaker_base_plot() +
theme(legend.position = c(0.2, 0.75),
panel.background = element_blank(),
panel.grid.major = element_line(gray(0.2)),
panel.border = element_rect(fill = NA))

expect_silent(tlc_legend)

})


0 comments on commit 87cf718

Please sign in to comment.