test_that("summary After sums to number of deduplicated records", {
imported <- data.frame(
id = c("A1", "B9"),
source = c("WOS", "SCOPUS"),
title = c("Effects of Arabidopsis stress", "Effects of Arabidopsis stress"),
year = c("2021", "2021"),
doi = c(NA, NA),
pages = c("252-257", "252-57"),
volume = c(NA, 4),
author = c("Smith J", "Smith J"),
abstract = c(NA, "Abstract text"),
issue = c("3", NA),
journal = c("Plant Journal", "Plant Journal"),
stringsAsFactors = FALSE
)
deduped <- data.frame(
id = "A1",
source = "WOS",
title = "X",
source_provenance = "WOS;SCOPUS",
stringsAsFactors = FALSE
)
summary_tbl <- summary_dedup(imported, deduped)
expect_equal(sum(summary_tbl$After), nrow(deduped))
})
## Attribution behavior test
test_that("merged records are attributed to primary source only", {
imported <- data.frame(
id = c("A1", "B9"),
source = c("WOS", "SCOPUS"),
title = c("Effects of Arabidopsis stress", "Effects of Arabidopsis stress"),
year = c("2021", "2021"),
doi = c(NA, NA),
pages = c("252-257", "252-57"),
volume = c(NA, 4),
author = c("Smith J", "Smith J"),
abstract = c(NA, "Abstract text"),
issue = c("3", NA),
journal = c("Plant Journal", "Plant Journal"),
stringsAsFactors = FALSE
)
deduped <- data.frame(
id = "A1",
source = "WOS",
title = "X",
source_provenance = "WOS;SCOPUS",
stringsAsFactors = FALSE
)
summary_tbl <- summary_dedup(imported, deduped)
expect_equal(
summary_tbl$After[summary_tbl$source == "SCOPUS"],
0
)
})