Add more tests for misc functions
Change-Id: I39210ef2d968eb5d5a671e24cbf3f1e4b9293d50
diff --git a/tests/testthat/test-demos.R b/tests/testthat/test-demos.R
index 8f99284..c0412ba 100644
--- a/tests/testthat/test-demos.R
+++ b/tests/testthat/test-demos.R
@@ -116,3 +116,11 @@
hc_freq_by_year_ci()
expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
})
+
+test_that("collocationScoreQuery works iwth hchart and hc_add_onclick_korap_search", {
+ kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE)
+ df <- collocationScoreQuery(kco,"Ameisenplage", "heimgesucht", leftContextSize=0, rightContextSize=1)
+ hc <- hchart(df, type="spline", hcaes(label, logDice))
+ hc <- hc_add_onclick_korap_search(hc)
+ expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
+})
diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R
new file mode 100644
index 0000000..197424b
--- /dev/null
+++ b/tests/testthat/test-misc.R
@@ -0,0 +1,33 @@
+test_that("queryStringToLabel works correctly", {
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /natur.*/ & creationDate in 2014"
+ )
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & pubDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & pubDate in 2014"
+ ), pubDateOnly = T
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & creationDate in 2014"
+ ), pubDateOnly = T
+ ),
+ c("2013", "2014"))
+
+ expect_equivalent(queryStringToLabel(
+ c(
+ "referTo=x & textClass = /natur.*/ & creationDate in 2013",
+ "referTo=x & textClass = /freizeit.*/ & creationDate in 2014"
+ ), excludePubDate = T
+ ),
+ c("/natur.*/", "/freizeit.*/"))
+})