testthat::test_that('Symbols', { mapData <- data.frame(x = 1:2, lng = c(-122, -121), lat = c(41,42)) m <- leaflet::leaflet() pal <- leaflet::colorNumeric('Reds', 1:4) # test args makeSymbol('notashape', width = 1, color = 'black') %>% testthat::expect_error() makeSymbol('rect', width = '1', color = 'black') %>% testthat::expect_error() makeSymbol('rect', width = 1, height = '1', color = 'black') %>% testthat::expect_error() makeSymbol('rect', width = 1, opacity = '1', color = 'black') %>% testthat::expect_error() makeSymbol('rect', width = 1, opacity = 1, fillOpacity = '1', color = 'black') %>% testthat::expect_error() makeSymbolIcons('notashape', width = 1, color = 'black') %>% testthat::expect_error() makeSymbolIcons('rect', width = '1', color = 'black') %>% testthat::expect_error() makeSymbolIcons('rect', width = 1, height = '1', color = 'black') %>% testthat::expect_error() makeSymbolIcons('rect', width = 1, opacity = '1', color = 'black') %>% testthat::expect_error() makeSymbolIcons('rect', width = 1, opacity = 1, fillOpacity = '1', color = 'black') %>% testthat::expect_error() makeSymbolIcons(NA, width = 1, height = 1, opacity = 1, color = 'black') %>% testthat::expect_error() makeLegendSymbol(shape = 'rect', width = 1, color = 'black') %>% testthat::expect_error() makeLegendSymbol(label = '', shape = 'rect', width = 1, color = 'black') %>% testthat::expect_error() m %>% addSymbols(lat = ~lat, lng = ~lng, data = mapData) %>% testthat::expect_error() m %>% addSymbols(lat = ~lat, lng = ~lng, color = 'black', values = 1:11, data = mapData) %>% testthat::expect_error() m %>% addSymbols(lat = ~lat, lng = ~lng, color = 'black', shape = c('rect', 'notashape'), values = ~x, data = mapData) %>% testthat::expect_error() m %>% addSymbolsSize(lat = ~lat, lng = ~lng, data = mapData) %>% testthat::expect_error() m %>% addSymbolsSize(lat = ~lat, lng = ~lng, values = ~x, data = mapData) %>% testthat::expect_error() m %>% addSymbolsSize(lat = ~lat, lng = ~lng, color = 'black', shape = c('notashape'), values = ~x, data = mapData) %>% testthat::expect_error() m %>% addSymbolsSize(lat = ~lat, lng = ~lng, color = 'black', baseSize = -1, values = ~x, data = mapData) %>% testthat::expect_error() # test shapes makeSymbol('rect', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('circle', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('triangle', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('plus', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('cross', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('diamond', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('star', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('stadium', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('line', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeSymbol('polygon', width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml,\n \n' ) makeLegendSymbol(label = '', labelStyle = '', shape = 'rect', width = 1, color = 'black') %>% as.character() %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> ') makeLegendSymbol(label = '', labelStyle = '', shape = 'rect', width = 1, color = 'black', orientation = 'horizontal') %>% as.character() %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> ') # test negative sizes sizeNumeric(values = 1:4, baseSize = -5) %>% testthat::expect_error() sizeBreaks(values = 1:4, breaks = 4, baseSize = -5) %>% testthat::expect_error() sizeBreaks(values = 1:4, breaks = -1, baseSize = 5) %>% testthat::expect_error() # test simple size outputs sizeNumeric(1:4, 5) %>% testthat::expect_equal(c(2, 4, 6, 8)) sizeBreaks(1:4, 4, 5) %>% testthat::expect_equal(stats::setNames(c(2, 4, 6, 8), c(1, 2, 3, 4))) sizeBreaks(1:4, 1:4, 5) %>% testthat::expect_equal(stats::setNames(c(2, 4, 6, 8), c(1, 2, 3, 4))) # test size icons args makeSymbolsSize(values = 1:4, shape = 'notashape', fillColor = 'black', color = 'black', baseSize = 5) %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = 'black', color = 'black', baseSize = -5) %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = 'black', color = 'black', baseSize = 5, opacity = '1') %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = c('rect', 'circle'), fillColor = 'black', color = 'black', baseSize = 5, opacity = 1) %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = 'black', color = 'black', baseSize = 5, opacity = 1, strokeWidth = -1) %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = 'rect', baseSize = 5, opacity = 1) %>% testthat::expect_error() makeSymbolsSize(values = 1:4, shape = 'rect', baseSize = 5, opacity = 1, color = 'black', fillColor = c('black', 'blue')) %>% testthat::expect_error() # test size icons makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = 'black', color = 'black', baseSize = 5)$iconUrl[[1]] %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml, ') makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = 'blue', color = 'black', baseSize = 5)$iconUrl[[2]] %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml, ') makeSymbolsSize(values = 1:4, shape = 'rect', color = pal(4:1), fillColor = pal(4:1), baseSize = 5)$iconUrl[[3]] %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml, ') makeSymbolsSize(values = 1:4, shape = 'rect', fillColor = pal(4:1), color = pal(1:4), baseSize = 5)$iconUrl[[4]] %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml, ') mapData <- data.frame(x = 1:2, lat = c(41,42), lng = c(-122, -122)) m %>% addSymbols(lat = ~lat, lng = ~lng, color = ~pal(x), fillColor = ~pal(x), values = ~x, data = mapData) %>% getElement('x') %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(3) %>% getElement('iconUrl') %>% getElement('data') %>% URLdecode() %>% testthat::expect_equal( c("data:image/svg+xml,\n \n", "data:image/svg+xml,\n \n" )) m %>% addSymbolsSize(lat = ~lat, lng = ~lng, color = ~pal(x), fillColor = ~pal(x), values = ~x, data = mapData) %>% getElement('x') %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(3) %>% getElement('iconUrl') %>% getElement('data') %>% URLdecode() %>% testthat::expect_equal( c("data:image/svg+xml,\n \n", "data:image/svg+xml,\n \n" )) drawPolygon(4) %>% testthat::expect_equal('0,0.5 0.5,0 1,0.5 0.5,1 0,0.5') symbolSvg('notashape', width = 20, height = 20, color = 'black', fillColor = 'black', opacity = 1, fillOpacity = 1) %>% testthat::expect_error() }) testthat::test_that('Symbol Legends', { mapData <- data.frame(x = 1:2) pal <- leaflet::colorNumeric('Reds', mapData[['x']]) factorPal <- leaflet::colorFactor('Set1', mapData[['x']]) m <- leaflet::leaflet() # test args m %>% addLegendSize(data = mapData, values = ~x) %>% testthat::expect_error() m %>% addLegendSize(data = mapData, values = ~x, pal = pal, fillColor = c('blue', 'red')) %>% testthat::expect_error() m %>% addLegendSize(data = mapData, values = ~x, color = 'black', numberFormat = 'fun') %>% testthat::expect_error() m %>% addLegendSize(data = mapData, values = ~x, color = 'black', shape = 'notashape') %>% testthat::expect_error() m %>% addLegendLine(data = mapData, values = ~x) %>% testthat::expect_error() m %>% addLegendLine(data = mapData, values = ~x) %>% testthat::expect_error() m %>% addLegendLine(data = mapData, values = ~x, color = 'black', numberFormat = 'fun') %>% testthat::expect_error() m %>% addLegendSymbol(data = mapData, values = ~x) %>% testthat::expect_error() m %>% addLegendSymbol(data = mapData, values = ~x, pal = factorPal, fillColor = c('blue', 'red', 'green')) %>% testthat::expect_error() m %>% addLegendSymbol(data = mapData, values = ~x, color = c('black', 'grey', 'blue'), pal = factorPal) %>% testthat::expect_error() m %>% addLegendSymbol(data = mapData, values = ~x, color = 'black', shape = c('rect', 'notashape')) %>% testthat::expect_error() m %>% addLegendSymbol(data = mapData, values = ~x, color = 'black', shape = c('rect')) %>% testthat::expect_error() # test size legends m %>% addLegendSize(data = mapData, values = ~x, pal = pal, breaks = 1, color = 'black') %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( '
" style="vertical-align: middle; margin: 5px; margin-right: 6.66666666666667px; margin-left: 6.66666666666667px" height="13.3333333333333" width="13.3333333333333"/> 1
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="26.6666666666667" width="26.6666666666667"/> 2
') # test line legends m %>% addLegendLine(data = mapData, values = ~x, color = 'black', breaks = 1) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( '
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="6.66666666666667" width="20"/> 1
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="13.3333333333333" width="20"/> 2
') m %>% addLegendSymbol(data = mapData, values = ~x, color = 'black', pal = factorPal) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( '
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="20" width="20"/> 1
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="20" width="20"/> 2
') # Stacked m %>% addLegendSize(color = 'black', fillColor = 'red', values = 1:5, stacked = TRUE, breaks = 2, shape = 'circle') %>% invisible() %>% testthat::expect_invisible() }) testthat::test_that('Image Legend', { m <- leaflet::leaflet() # test addLegendImage Args colors <- c('blue', 'red', 'yellow', 'green', 'orange', 'purple') leafImg <- system.file(sprintf('img/leaf-%s.png', colors), package = 'leaflegend') testthat::expect_error(m %>% addLegendImage(images = leafImg, labels = colors, orientation = 'up')) testthat::expect_error(m %>% addLegendImage(images = leafImg, labels = colors, title = 1:2)) testthat::expect_error(m %>% addLegendImage(images = seq_along(colors), labels = colors)) testthat::expect_error(m %>% addLegendImage(images = leafImg[1:2], labels = colors)) testthat::expect_error(m %>% addLegendImage(images = leafImg, labels = colors[1:2])) testthat::expect_error(m %>% addLegendImage(images = leafImg, labels = colors, width = -1)) testthat::expect_error(m %>% addLegendImage(images = leafImg, labels = colors, height = -1)) # test addLegendImage legends rectImg <- system.file('img/rect.png', package = 'leaflegend') m %>% addLegendImage(images = rectImg, labels = 'rect', orientation = 'horizontal') %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% testthat::expect_equal( ' rect ' ) m %>% addLegendImage( images = makeSymbol('rect', width = 10, color = 'black'), labels = 'rect') %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( '
" style="vertical-align: middle; margin: 5px; margin-right: 0px; margin-left: 0px" height="20" width="20"/> rect
' ) }) testthat::test_that('Numeric Legend', { mapData <- data.frame(x = 1:3) m <- leaflet::leaflet(mapData) pal <- leaflet::colorNumeric('Reds', mapData[['x']]) # test args m %>% addLegendNumeric(pal = pal, values = ~x, orientation = 'up') %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, title = 1:2) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, shape = 'circle') %>% testthat::expect_error() # is this test necessary m %>% addLegendNumeric(pal = pal, values = ~x, width = -1) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, height = -1) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, numberFormat = 'fun') %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, bins = -1) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, decreasing = NULL) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, decreasing = 'TRUE') %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, tickLength = -1) %>% testthat::expect_error() m %>% addLegendNumeric(pal = pal, values = ~x, tickWidth = -1) %>% testthat::expect_error() # test results numVert <- m %>% addLegendNumeric(pal = pal, values = c(1, NA, 3)) numHori <- m %>% addLegendNumeric(pal = pal, values = c(1, NA, 3), orientation = 'horizontal', width = 100, height = 20) # numVert %>% # getElement('x') %>% # getElement('calls') %>% # getElement(1) %>% # getElement('args') %>% # getElement(1) %>% # strsplit('% # getElement(1) %>% # getElement(1) %>% # testthat::expect_equal( # expected = '
#
# # # # # # # # # # # # # # # # # #
#
#
1.5
#
2
#
2.5
#
#
#
#
# ') # numVert %>% # getElement('x') %>% # getElement('calls') %>% # getElement(1) %>% # getElement('args') %>% # getElement(1) %>% # strsplit('% # getElement(1) %>% # getElement(2) %>% # sprintf(fmt = '%2$s%1$s', '% # URLdecode() %>% # testthat::expect_equal( # expected = ' # # " style="vertical-align: middle; margin: 1px;"/> # NA #
') # numHori %>% # getElement('x') %>% # getElement('calls') %>% # getElement(1) %>% # getElement('args') %>% # getElement(1) %>% # strsplit('% # getElement(1) %>% # sprintf(fmt = '%2$s%1$s', c('', '% # mapply(function(x,fun) fun(x), x = ., fun = c(identity, URLdecode)) %>% # paste0(collapse = '\n') %>% # testthat::expect_equal( # '
# # # # # # # # # # # # # #
#
#
1
#
3
#
#
# # # # " style="vertical-align: middle; margin: 1px;"/> # NA #
') }) testthat::test_that('Categorical Legends', { # test Quantile args mapData <- data.frame(x = 1:10, y = rep(LETTERS[1:2], 5)) m <- leaflet::leaflet(mapData) palQuantile <- leaflet::colorQuantile('Reds', mapData[['x']], n = 2) palBin <- leaflet::colorBin('Blues', mapData[['x']], bins = 2) palFactor <- leaflet::colorFactor('viridis', mapData[['y']]) # test Quantile args m %>% addLegendQuantile(pal = palQuantile, values = ~x, orientation = 'up') %>% testthat::expect_error() m %>% addLegendQuantile(pal = palQuantile, values = ~x, title = 1:2) %>% testthat::expect_error() m %>% addLegendQuantile(pal = palQuantile, values = ~x, shape = 'notashape') %>% testthat::expect_error() m %>% addLegendQuantile(pal = palQuantile, values = ~x, width = -1) %>% testthat::expect_error() m %>% addLegendQuantile(pal = palQuantile, values = ~x, height = -1) %>% testthat::expect_error() m %>% addLegendQuantile(pal = palQuantile, values = ~x, numberFormat = 'fun') %>% testthat::expect_error() # test Bin args m %>% addLegendBin(pal = palBin, orientation = 'up') %>% testthat::expect_error() m %>% addLegendBin(pal = palBin, title = 1:2) %>% testthat::expect_error() m %>% addLegendBin(pal = palBin, shape = 'notashape') %>% testthat::expect_error() m %>% addLegendBin(pal = palBin, width = -1) %>% testthat::expect_error() m %>% addLegendBin(pal = palBin, height = -1) %>% testthat::expect_error() m %>% addLegendBin(pal = palBin, numberFormat = 'fun') %>% testthat::expect_error() # test Factor args m %>% addLegendFactor(pal = palFactor, values = ~y, orientation = 'up') %>% testthat::expect_error() m %>% addLegendFactor(pal = palFactor, values = ~y, title = 1:2) %>% testthat::expect_error() m %>% addLegendFactor(pal = palFactor, values = ~y, shape = 'notashape') %>% testthat::expect_error() m %>% addLegendFactor(pal = palFactor, values = ~y, width = -1) %>% testthat::expect_error() m %>% addLegendFactor(pal = pal, values = ~y, height = -1) %>% testthat::expect_error() m %>% addLegendFactor(pal = palFactor, values = ~y, numberFormat = 'fun') %>% testthat::expect_error() # test results m %>% addLegendQuantile(pal = palQuantile, values = ~x) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% strsplit('\n') %>% getElement(1) %>% lapply(function(x) { if ( substring(x, 2,4) == 'img' ) { URLdecode(x) } else { x } } ) %>% paste0(collapse = '\n') %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> 0% - 50% (1 - 6)
" style="vertical-align: middle; margin: 1px;"/> 50% - 100% (6 - 10)
') m %>% addLegendBin(pal = palBin, values = ~x) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> 0 - 5
" style="vertical-align: middle; margin: 1px;"/> 5 - 10
') m %>% addLegendFactor(pal = palFactor, values = ~y) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> A
" style="vertical-align: middle; margin: 1px;"/> B
') }) testthat::test_that('Awesome Legends', { m <- leaflet::leaflet() iconSet <- leaflet::awesomeIconList( 'home' = leaflet::makeAwesomeIcon() ) # test args m %>% addLegendAwesomeIcon(iconSet = list()) %>% testthat::expect_error() m %>% addLegendAwesomeIcon( iconSet = leaflet::awesomeIconList(leaflet::makeAwesomeIcon())) %>% testthat::expect_error() m %>% addLegendAwesomeIcon(iconSet = iconSet, marker = NA) %>% testthat::expect_error() # test results m %>% addLegendAwesomeIcon(iconSet = iconSet) %>% getElement('dependencies') %>% vapply(getElement, 'name', FUN.VALUE = character(1)) %>% testthat::expect_contains(c('leaflet-awesomemarkers', 'bootstrap')) m %>% addLegendAwesomeIcon(iconSet = iconSet) %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% testthat::expect_equal( '
home
') m %>% addLegendAwesomeIcon(iconSet = iconSet, orientation = 'horizontal', title = 'Icons') %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(1) %>% testthat::expect_equal( '
Icons
home
' ) }) testthat::test_that('Helper Functions', { parseValues(1:2) %>% testthat::expect_equal(1:2) m <- leaflet::leaflet() m %>% leaflegendAddControl(html = '

Test

', group = 'Test') %>% testthat::expect_error() m %>% leaflegendAddControl(className = '', group = 'Test') %>% testthat::expect_error() m %>% leaflegendAddControl(html = '',className = '', group = 'Test') %>% getElement(1) %>% getElement('calls') %>% getElement(1) %>% getElement('args') %>% getElement(4) %>% testthat::expect_equal(' leaflegend-group-Test') leafletAwesomeMarkersDependencies() %>% testthat::expect_equal(leaflet:::leafletAwesomeMarkersDependencies()) leafletAmFontAwesomeDependencies() %>% testthat::expect_equal(leaflet:::leafletAmFontAwesomeDependencies()) leafletAmIonIconDependencies() %>% testthat::expect_equal(leaflet:::leafletAmIonIconDependencies()) leafletAmBootstrapDependencies() %>% testthat::expect_equal(leaflet:::leafletAmBootstrapDependencies()) coalesceMissing(y = 1L) %>% testthat::expect_equal(1L) coalesceMissing(x = 2L, y = 1L) %>% testthat::expect_equal(2L) coalesceMissing(x = 1L) %>% testthat::expect_equal(1L) }) testthat::test_that('pch', { defaultSize <- 20 makeSymbol(shape = -1, width = defaultSize, color = 'black') |> testthat::expect_error() makeSymbol(shape = 1.5, width = defaultSize, color = 'black') |> testthat::expect_error() makeSymbol(shape = 26, width = defaultSize, color = 'black') |> testthat::expect_error() makeLegendSymbol(label = '', labelStyle = '', shape = 'open-rect', width = 1, color = 'black', orientation = 'horizontal') %>% as.character() %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> ') makeLegendSymbol(label = '', labelStyle = '', shape = 0, width = 1, color = 'black', orientation = 'horizontal') %>% as.character() %>% URLdecode() %>% testthat::expect_equal( ' " style="vertical-align: middle; margin: 1px;"/> ') makeSymbol(availableShapes()[['pch']][26], width = 1, height = 2, color = 'black', fillColor = 'blue', opacity = .9, fillOpacity = .7) %>% URLdecode() %>% testthat::expect_equal( 'data:image/svg+xml, ') pchSvg('notashape', width = 20, height = 20, color = 'black', fillColor = 'black', opacity = 1, fillOpacity = 1, `stroke-width` = 2) %>% testthat::expect_error() }) testthat::test_that('utils', { addTitle(htmltools::div('title'), list()) %>% as.character() %>% testthat::expect_equal('
title
') addNa(hasNa = TRUE, htmlElements = list(), shape = 'rect', labels = 'NA', colors = 'grey', labelStyle = '', height = 10, width = 10, opacity = 1, fillOpacity = 1, strokeWidth = 0) %>% as.character() %>% URLdecode() %>% testthat::expect_equal('
" style="vertical-align: middle; margin: 1px;"/> NA
') verifyIconLibrary('bad') %>% testthat::expect_error() })