Skip to content

Commit

Permalink
feat: simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Feb 9, 2021
1 parent b3dadd6 commit 58adc11
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ jobs:
run: devtools::check('r_package', args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check")
shell: Rscript {0}

- name: Test
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: devtools::test('r_package')
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
Expand Down
12 changes: 6 additions & 6 deletions r_package/R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ fromList = function(upsetjs,
else
sorted_sets

gen = if (c_type == "none") list() else if (isVennDiagram(upsetjs) || isKarnaughMap(upsetjs)) {
gen = if (!is.null(c_type) && c_type == "none") list() else if (isVennDiagram(upsetjs) || isKarnaughMap(upsetjs)) {
generateCombinationsImpl(
gen_sets,
if_else(is.null(c_type), 'distinctIntersection', c_type),
ifelse(is.null(c_type), 'distinctIntersection', c_type),
0,
NULL,
TRUE,
Expand All @@ -208,7 +208,7 @@ fromList = function(upsetjs,
} else {
generateCombinationsImpl(
gen_sets,
if_else(is.null(c_type), 'intersection', c_type),
ifelse(is.null(c_type), 'intersection', c_type),
0,
NULL,
FALSE,
Expand Down Expand Up @@ -437,10 +437,10 @@ fromDataFrame = function(upsetjs,

elems = rownames(df)

gen = if (c_type == "none") list() else if (isVennDiagram(upsetjs) || isKarnaughMap(upsetjs)) {
gen = if (!is.null(c_type) && c_type == "none") list() else if (isVennDiagram(upsetjs) || isKarnaughMap(upsetjs)) {
generateCombinationsImpl(
gen_sets,
if_else(is.null(c_type), 'distinctIntersection', c_type),
ifelse(is.null(c_type), 'distinctIntersection', c_type),
0,
NULL,
TRUE,
Expand All @@ -451,7 +451,7 @@ fromDataFrame = function(upsetjs,
} else {
generateCombinationsImpl(
gen_sets,
if_else(is.null(c_type), 'intersection', c_type),
ifelse(is.null(c_type), 'intersection', c_type),
0,
NULL,
FALSE,
Expand Down
21 changes: 19 additions & 2 deletions r_package/tests/testthat/test-data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
test_that("multiplication works", {
expect_equal(2 * 2, 4)
upsetjs_mock = function() {
x = structure(list(mode = 'hover',
sets = c()))

r = list(
x=x,
package = 'upsetjs'
)
class(r) = c(class(r), 'upsetjs_common', 'upsetjs_upset')
r
}


test_that("fromList", {
listInput <- list(one = c('a', 'b', 'c', 'e', 'g', 'h', 'k', 'l', 'm'), two = c('a', 'b', 'd', 'e', 'j'), three = c('a', 'e', 'f', 'g', 'h', 'i', 'j', 'l', 'm'))

sets <- upsetjs_mock() %>% fromList(listInput) %>% getSets()
expect_equal(length(sets), 0)
expect_equal(2, 2)
})

0 comments on commit 58adc11

Please sign in to comment.