Skip to content

Commit 87cf718

Browse files
committed
First example of tests. Add for non-plotting functions
1 parent 7b382e6 commit 87cf718

File tree

6 files changed

+42
-3
lines changed

6 files changed

+42
-3
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
^html$
1313
^\.RData
1414
^appveyor\.yml$
15+
^codecov\.yml$

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ License: MIT + file LICENSE
1212
BugReports: https://github.com/valentinitnelav/plotbiomes/issues
1313
Depends:
1414
R (>= 3.1)
15-
Imports:
15+
Imports:
1616
data.table (>= 1.10.4-3),
1717
ggplot2 (>= 2.2.1),
1818
mapview (>= 2.3.0),
1919
sp (>= 1.2-7)
20-
Suggests:
20+
Suggests:
2121
grImport,
2222
sf,
2323
knitr,
2424
raster,
2525
roxygen2,
2626
plotly,
27-
covr
27+
covr,
28+
testthat
2829
Encoding: UTF-8
2930
LazyData: true
3031
RoxygenNote: 6.0.1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<!-- CI badges -->
44
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/jag1bo7jaao5jid3/branch/develop?svg=true)](https://ci.appveyor.com/project/valentinitnelav/plotbiomes/branch/develop)
55
[![Travis Build Status](https://travis-ci.org/valentinitnelav/plotbiomes.svg?branch=develop)](https://travis-ci.org/valentinitnelav/plotbiomes)
6+
[![Coverage Status](https://img.shields.io/codecov/c/github/valentinitnelav/plotbiomes/master.svg)](https://codecov.io/github/valentinitnelav/plotbiomes?branch=master)
7+
68
<!--
79
Fixing errors from Travis CI can be time consuming ...
810
I gave up since the effort to fix the errors is not worth the time!

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: false

tests/testthat.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(plotbiomes)
3+
4+
test_check("plotbiomes")

tests/testthat/test-base_plot.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# test whittaker_base_plot()
2+
context('Whittaker base plot')
3+
4+
library(ggplot2)
5+
6+
test_plot <- whittaker_base_plot()
7+
8+
9+
10+
test_that('function and arguments work correctly', {
11+
12+
expect_true(inherits(test_plot, 'ggplot'))
13+
14+
# colors are named properly when not user specified
15+
colors <- gray(0:9 / 9)
16+
17+
expect_message(whittaker_base_plot(color_palette = colors),
18+
regexp = "Names for 'color_palette'")
19+
20+
tlc_legend <- whittaker_base_plot() +
21+
theme(legend.position = c(0.2, 0.75),
22+
panel.background = element_blank(),
23+
panel.grid.major = element_line(gray(0.2)),
24+
panel.border = element_rect(fill = NA))
25+
26+
expect_silent(tlc_legend)
27+
28+
})
29+
30+

0 commit comments

Comments
 (0)