Skip to content

Commit

Permalink
Added test for margin sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
AdeelK93 committed Mar 19, 2017
1 parent 0deca0e commit 73fca2b
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 42 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ shiny::runApp(system.file("examples/03shiny", package = "collapsibleTree"))
``` r
library(collapsibleTree)
date()
#> [1] "Sun Mar 19 18:08:24 2017"
#> [1] "Sun Mar 19 18:37:10 2017"

testthat::test_dir("tests/testthat")
#> Error handling: ..........
#> Margin sizing: ................
#> Root labelling: ..........
#>
#> DONE ======================================================================
Expand Down
14 changes: 7 additions & 7 deletions docs/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ load(system.file("extdata/Geography.rda", package = "collapsibleTree"))
## Overview

collapsibleTree is an R [htmlwidget](http://www.htmlwidgets.org/) that allows you to create interactive collapsible Reingold–Tilford tree diagrams using D3.js, adapted from Mike Bostock's [example](https://bl.ocks.org/mbostock/4339083). Turn your data frame into a hierarchical visualization without worrying about nested lists or JSON objects!

If you're using [Shiny](https://shiny.rstudio.com/), you can bind the most recently clicked node to a Shiny input, allowing for easier interaction with complex nested objects. The input will return a named list containing the most recently selected node, as well as all of its parents. See the [Shiny example](https://adeelk93.shinyapps.io/collapsibletree/) for more info.

## Installation
Expand Down Expand Up @@ -95,12 +95,12 @@ countryColors <- Geography %>%
Geography %>%
arrange(continent, type, country) %>%
collapsibleTree(
hierarchy = c("continent", "type", "country"),
root = "Geography",
width = 800,
fill = c("white", continentColors, typeColors$colors, countryColors$colors)
)
collapsibleTree(
hierarchy = c("continent", "type", "country"),
root = "Geography",
width = 800,
fill = c("white", continentColors, typeColors$colors, countryColors$colors)
)
```

## Basing Gradients on a Numeric Column
Expand Down
28 changes: 14 additions & 14 deletions docs/index.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions inst/examples/01rmd/Example01.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ countryColors <- Geography %>%
Geography %>%
arrange(continent, type, country) %>%
collapsibleTree(
hierarchy = c("continent", "type", "country"),
root = "Geography",
width = 800,
fill = c("white", continentColors, typeColors$colors, countryColors$colors)
)
collapsibleTree(
hierarchy = c("continent", "type", "country"),
root = "Geography",
width = 800,
fill = c("white", continentColors, typeColors$colors, countryColors$colors)
)
```

## Basing Gradients on a Numeric Column
Expand Down
28 changes: 14 additions & 14 deletions inst/examples/01rmd/Example01.html

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions tests/testthat/test-margin.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
library(collapsibleTree)
library(tibble)
load(system.file("extdata/Geography.rda", package = "collapsibleTree"))
context("Margin sizing")

geo <- collapsibleTree(
Geography,
hierarchy = c("continent", "type", "country")
)
geoSummary <- collapsibleTreeSummary(
Geography,
hierarchy = c("continent", "type", "country")
)

test_that("left margins are the correct size - data frame", {
expect_gt(geo$x$options$margin$left, 50)
expect_gt(geoSummary$x$options$margin$left, 50)
expect_lt(geo$x$options$margin$left, 100)
expect_lt(geoSummary$x$options$margin$left, 100)
})

test_that("right margins are the correct size - data frame", {
expect_gt(geo$x$options$margin$right, 250)
expect_gt(geoSummary$x$options$margin$right, 250)
expect_lt(geo$x$options$margin$right, 300)
expect_lt(geoSummary$x$options$margin$right, 300)
})

Geography <- as_tibble(Geography)
geo <- collapsibleTree(
Geography,
hierarchy = c("continent", "type", "country")
)
geoSummary <- collapsibleTreeSummary(
Geography,
hierarchy = c("continent", "type", "country")
)

test_that("left margins are the correct size - tibble", {
expect_gt(geo$x$options$margin$left, 50)
expect_gt(geoSummary$x$options$margin$left, 50)
expect_lt(geo$x$options$margin$left, 100)
expect_lt(geoSummary$x$options$margin$left, 100)
})

test_that("right margins are the correct size - tibble", {
expect_gt(geo$x$options$margin$right, 250)
expect_gt(geoSummary$x$options$margin$right, 250)
expect_lt(geo$x$options$margin$right, 300)
expect_lt(geoSummary$x$options$margin$right, 300)
})

0 comments on commit 73fca2b

Please sign in to comment.