From e17146be886e4c15b0de7abd2e953e56cd1453c7 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Wed, 17 Jan 2024 00:02:03 -0500 Subject: [PATCH 1/3] Wrap anchor tag in span with `white-space` style set --- R/format_data.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/format_data.R b/R/format_data.R index f57fedf11d..1647335266 100644 --- a/R/format_data.R +++ b/R/format_data.R @@ -9295,12 +9295,14 @@ fmt_url <- function( x_str_non_missing <- paste0( + "", "", label_str, - "" + "", + "" ) x_str[!is.na(x)] <- x_str_non_missing From eac0daf8a87d98330a4ab59371f69de31be3fed8 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Wed, 17 Jan 2024 00:02:06 -0500 Subject: [PATCH 2/3] Update test-fmt_url.R --- tests/testthat/test-fmt_url.R | 156 +++++++++++++++++----------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/tests/testthat/test-fmt_url.R b/tests/testthat/test-fmt_url.R index 5d8e0d5b8e..fd95f0b6f8 100644 --- a/tests/testthat/test-fmt_url.R +++ b/tests/testthat/test-fmt_url.R @@ -31,9 +31,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -42,9 +42,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, label = "static label") %>% render_formats_test(context = "html"))[["a"]], c( - "static label", - "static label", - "static label", + "static label", + "static label", + "static label", NA ) ) @@ -53,9 +53,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -64,9 +64,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, color = "forestgreen") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -75,9 +75,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, show_underline = FALSE) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -86,9 +86,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, show_underline = TRUE) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -97,9 +97,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -108,9 +108,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -119,9 +119,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black", button_width = px(500)) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -130,9 +130,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black", button_width = pct(80)) %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -141,9 +141,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "auto", color = "black") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -152,9 +152,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "auto", color = "#FFFADF") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -163,9 +163,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "auto", color = "#FFFADF", button_outline = "pink") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -174,9 +174,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "#FFFFFF", button_outline = "auto") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -185,9 +185,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "#FAD5EF", button_outline = "auto") %>% render_formats_test(context = "html"))[["a"]], c( - "http://www.example.com", - "https://developer.mozilla.org/en-US/docs/Learn/", - "https://developer.mozilla.org/en-US/search?q=URL", + "http://www.example.com", + "https://developer.mozilla.org/en-US/docs/Learn/", + "https://developer.mozilla.org/en-US/search?q=URL", NA ) ) @@ -212,9 +212,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -222,9 +222,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, label = "static label") %>% render_formats_test(context = "html"))[["a"]], c( - "static label", - "static label", - "static label" + "static label", + "static label", + "static label" ) ) expect_equal( @@ -232,9 +232,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -242,9 +242,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, color = "forestgreen") %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -252,9 +252,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, show_underline = FALSE) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -262,9 +262,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, show_underline = TRUE) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -272,9 +272,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red") %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -282,9 +282,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black") %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -292,9 +292,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black", button_width = px(500)) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -302,9 +302,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, as_button = TRUE, button_fill = "red", color = "black", button_width = pct(80)) %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) expect_equal( @@ -312,9 +312,9 @@ test_that("The `fmt_url()` function works correctly", { fmt_url(columns = a, hreflang = "en-GB", target = "_blank", rel = "external", referrerpolicy = "no-referrer") %>% render_formats_test(context = "html"))[["a"]], c( - "Example Site", - "Learn at Mozilla", - "Search Mozilla" + "Example Site", + "Learn at Mozilla", + "Search Mozilla" ) ) From 021c8c9d9f537ef51fcb7301b5f57861e693a598 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Wed, 17 Jan 2024 00:29:42 -0500 Subject: [PATCH 3/3] Update test-helper_functions.R --- tests/testthat/test-helper_functions.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-helper_functions.R b/tests/testthat/test-helper_functions.R index b01456ae68..1d50fad392 100644 --- a/tests/testthat/test-helper_functions.R +++ b/tests/testthat/test-helper_functions.R @@ -541,14 +541,14 @@ test_that("The `from_column()` helper works correctly", { render_formats_test("html") )[["url"]], c( - "apricot", - "banana", - "coconut", - "durian", - "missing", - "fig", - "grapefruit", - "honeydew" + "apricot", + "banana", + "coconut", + "durian", + "missing", + "fig", + "grapefruit", + "honeydew" ) ) })