-
Notifications
You must be signed in to change notification settings - Fork 78
/
test-venues.R
114 lines (108 loc) · 2.75 KB
/
test-venues.R
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
test_that("venue = 'gh' works with/without leading prose", {
skip_on_cran()
input <- c(
"#' Hello world",
"## comment",
"1:5"
)
output <- c(
"Hello world",
"",
"``` r",
"## comment",
"1:5",
"#> [1] 1 2 3 4 5",
"```"
)
ret <- reprex(input = input, venue = "gh", advertise = FALSE)
expect_identical(ret, output)
input <- grep("Hello", input, invert = TRUE, value = TRUE)
output <- grep("Hello", output, invert = TRUE, value = TRUE)
output <- output[nzchar(output)]
ret <- reprex(input = input, venue = "gh", advertise = FALSE)
expect_identical(ret, output)
})
test_that("venue = 'R' works, regardless of case", {
skip_on_cran()
input <- c(
"#' Hello world",
"## comment",
"1:5"
)
output <- c(
"#' Hello world",
"## comment",
"1:5",
"#> [1] 1 2 3 4 5"
)
ret <- reprex(input = input, venue = "R", advertise = FALSE)
expect_identical(ret[nzchar(ret)], output)
ret <- reprex(input = input, venue = "r", advertise = FALSE)
expect_identical(ret[nzchar(ret)], output)
})
test_that("venues = 'ds' and 'so' are aliases for 'gh'", {
skip_on_cran()
input <- c(
"#' Hello world",
"## comment",
"1:5"
)
ds <- reprex(input = input, venue = "ds", session_info = TRUE, advertise = FALSE)
so <- reprex(input = input, venue = "so", session_info = TRUE, advertise = FALSE)
gh <- reprex(input = input, venue = "gh", session_info = TRUE, advertise = FALSE)
expect_identical(so, gh)
expect_identical(ds, gh)
})
test_that("local image link is not interrupted by hard line break for 'gh'", {
skip_on_cran()
input <- c(
"#+ setup, include = FALSE",
"knitr::opts_knit$set(upload.fun = identity)",
"",
"#+ incredibly-long-chunk-name-to-make-image-path-also-incredibly-long",
"plot(1:3)"
)
out <- reprex(input = input, venue = "gh")
line <- grep("incredibly-long", out, value = TRUE)
expect_length(line, 1)
expect_match(line, "[)]")
})
test_that("venue = 'html' works", {
skip_on_cran()
input <- c(
"#' Hello world",
"## comment",
"1:5"
)
output <- c(
"<head>",
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">",
"</head>",
"<p>Hello world</p>",
"<pre class=\"r\"><code>## comment",
"1:5",
"#> [1] 1 2 3 4 5</code></pre>"
)
ret <- reprex(input = input, venue = "html", advertise = FALSE)
ret <- ret[nzchar(ret)]
expect_identical(ret, output)
})
test_that("venue = 'slack' works", {
skip_on_cran()
input <- c(
"#' Hello world",
"## comment",
"1:5"
)
output <- c(
"Hello world",
"```",
"## comment",
"1:5",
"#> [1] 1 2 3 4 5",
"```"
)
ret <- reprex(input = input, venue = "slack")
ret <- ret[nzchar(ret)]
expect_identical(ret, output)
})