File: test-utils-multi.R

package info (click to toggle)
r-cran-httr2 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,604 kB
  • sloc: sh: 21; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
test_that("can handle multi query params", {
  expect_equal(
    multi_dots(a = 1:2, .multi = "explode"),
    list(a = I("1"), a = I("2"))
  )
  expect_equal(
    multi_dots(a = 1:2, .multi = "comma"),
    list(a = I("1,2"))
  )
  expect_equal(
    multi_dots(a = 1:2, .multi = "pipe"),
    list(a = I("1|2"))
  )
  expect_equal(
    multi_dots(a = 1:2, .multi = function(x) "X"),
    list(a = I("X"))
  )
})

test_that("can opt-out of escaping for' vectors", {
  expect_equal(
    multi_dots(a = I(c(" ", " ")), .multi = "comma"),
    list(a = I(" , "))
  )
})

test_that("can handle empty dots", {
  expect_equal(multi_dots(), list())
})

test_that("preserves NULL values", {
  expect_equal(multi_dots(x = NULL), list(x = NULL))
})

test_that("preserves duplicates values", {
  expect_equal(multi_dots(x = 1, x = 2), list(x = I("1"), x = I("2")))
})

test_that("leaves already escaped values alone", {
  x <- I("1 + 2")
  expect_equal(multi_dots(x = x), list(x = x))
})

test_that("checks its inputs", {
  expect_snapshot(error = TRUE, {
    multi_dots(1)
    multi_dots(x = I(1))
    multi_dots(x = 1:2)
    multi_dots(x = mean)
  })
})