-
Notifications
You must be signed in to change notification settings - Fork 14
/
test-div.R
100 lines (87 loc) · 2.58 KB
/
test-div.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
testthat::context("divs")
test_css <- htmltools::css(marginLeft='auto',marginRight='auto')
testthat::describe('slick div types',{
it('img default',{
testthat::expect_equal(
slick_div(nba_team_logo$uri[1]),
list(htmltools::img(src = as.character(nba_team_logo$uri[1]), style = test_css))
)
})
it('img vector',{
testthat::expect_equal(
slick_div(nba_team_logo$uri[c(1,2)]),
lapply(nba_team_logo$uri[c(1,2)], function(x,css) htmltools::img(src = x, style = css),css = test_css)
)
})
it('img file',{
testthat::expect_equal(
slick_div('../assets/img1.png'),
list(htmltools::img(src = readImage('../assets/img1.png'), style = test_css))
)
})
it('img link',{
testthat::expect_equal(
slick_div(nba_player_logo$uri[1],links = nba_player_logo$player_home[1]),
list(
htmltools::a(
htmltools::img(src = nba_player_logo$uri[1], style = test_css),
href = nba_player_logo$player_home[1], target="_blank"
))
)
})
it('p',{
testthat::expect_equal(
slick_div('1234',type = 'p'),
list(htmltools::p('1234', style = test_css))
)
})
it('iframe',{
testthat::expect_equal(
slick_div('1234',type = 'iframe'),
list(htmltools::tags$iframe(srcdoc = '1234', style = test_css))
)
})
})
testthat::describe('slick list',{
it('dots',{
testthat::expect_equal(
slick_list(slick_div(nba_player_logo$uri[1],type = 'img'),
slick_div(nba_player_logo$uri[2],type = 'img')
),
htmltools::tagList(
list(htmltools::div(
list(htmltools::img(src = as.character(nba_player_logo$uri[1]), style = test_css))
),
htmltools::div(
list(htmltools::img(src = as.character(nba_player_logo$uri[2]), style = test_css))
)
)
)
)
})
it('list',{
testthat::expect_equal(
slick_list(list(slick_div(nba_player_logo$uri[1],type = 'img'),
slick_div(nba_player_logo$uri[2],type = 'img'))
),
htmltools::tagList(
list(htmltools::div(
list(htmltools::img(src = as.character(nba_player_logo$uri[1]), style = test_css))
),
htmltools::div(
list(htmltools::img(src = as.character(nba_player_logo$uri[2]), style = test_css))
)
)
)
)
})
})
testthat::describe('slick outer div',{
it('wrap div',{
testthat::expect_equal(
{set.seed(123)
outer_div(slick_div(nba_team_logo$uri[1]),id = '123')},
readRDS('../assets/outer_div.Rds')
)
})
})