test_that("The data frame to enrich must be a data frame", {
  expect_error(
    enrich(
      dataframe = 1,
      catalogue = tibble(),
      joinBy = "",
      enrichedColumnName = "")
  )
})

test_that("The catalogue must be a data frame", {
  expect_error(
    enrich(
      dataframe = tibble(),
      catalogue = 1,
      joinBy = "",
      enrichedColumnName = "")
  )
})

test_that("The catalogue must contain the NAME and CODE columns", {
  expect_error(
    enrich(
      dataframe = tibble(),
      catalogue = tibble(),
      joinBy = "",
      enrichedColumnName = "")
  )
})

test_that("The join key must be a string", {
  expect_error(
    enrich(
      dataframe = tibble(),
      catalogue = tibble(),
      joinBy = 1,
      enrichedColumnName = "")
  )
})

test_that("The enriched column name must be a string", {
  expect_error(
    enrich(
      dataframe = tibble(),
      catalogue = tibble(),
      joinBy = "",
      enrichedColumnName = 1)
  )
})

test_that("A data frame must be returned", {
  dataframe_ <- iris |> dplyr::rename(CODE = Species)

  catalogue_ <- iris |>
    dplyr::rename(CODE = Species) |>
    dplyr::mutate(NAME = "test") |>
    dplyr::select(CODE, NAME) |>
    unique()

  enriched_ <- enrich(
    dataframe = dataframe_,
    catalogue = catalogue_,
    joinBy = "CODE",
    enrichedColumnName = "enrichedColumn")

  expect_true(is.data.frame(enriched_))
})
