Skip to content

Commit

Permalink
tests: adds test with valid symbol but backticked and corrected titles
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 16, 2024
1 parent 0a894df commit 25d3694
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tests/testthat/test-get_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ testthat::test_that("data() call is returned when data name is provided as a cha
)
})

testthat::describe("Backticked special symbols", {
testthat::it("starting with underscore code dependency is being detected", {
testthat::describe("Backticked symbol", {
testthat::it("starting with underscore is detected in code dependency", {
td <- teal_data() |>
within({
`_add_column_` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)

Check warning on line 703 in tests/testthat/test-get_code.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-get_code.R,line=703,col=9,[object_name_linter] Variable and function name style should match snake_case or symbols.
Expand All @@ -714,7 +714,7 @@ testthat::describe("Backticked special symbols", {
)
})

testthat::it("with spaces code dependency is being detected", {
testthat::it("with space character is detected in code dependency", {
td <- teal_data() |>
within({
`add column` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)

Check warning on line 720 in tests/testthat/test-get_code.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-get_code.R,line=720,col=9,[object_name_linter] Variable and function name style should match snake_case or symbols.
Expand All @@ -731,7 +731,24 @@ testthat::describe("Backticked special symbols", {
)
})

testthat::it("with non-native pipe code dependency is being detected", {
testthat::it("without special characters is cleaned and detecteed in code dependency", {
td <- teal_data() |>
within({
`add_column` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)
IRIS <- `add_column`(iris, dplyr::tibble(new_col = "new column"))

Check warning on line 738 in tests/testthat/test-get_code.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-get_code.R,line=738,col=9,[object_name_linter] Variable and function name style should match snake_case or symbols.
})

testthat::expect_identical(
get_code(td, datanames = "IRIS"),
paste(
sep = "\n",
"add_column <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)",
"IRIS <- add_column(iris, dplyr::tibble(new_col = \"new column\"))"
)
)
})

testthat::it("with non-native pipe is detected code dependency", {
td <- teal_data() |>
within({
`%add_column%` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)
Expand Down

0 comments on commit 25d3694

Please sign in to comment.