# agridatasets - A Comprehensive Collection of Agricultural and Agronomic Datasets
# Version 0.1.1
# Copyright (C) 2026 Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# avocado_us_sale

library(testthat)

# Test 1: Check that the object is a tibble/data.frame and has 11 columns
test_that("avocado_us_sale is a tibble data.frame with 11 columns", {
  expect_s3_class(avocado_us_sale, "tbl_df")
  expect_s3_class(avocado_us_sale, "tbl")
  expect_s3_class(avocado_us_sale, "data.frame")
  expect_equal(ncol(avocado_us_sale), 11)
  expect_equal(length(avocado_us_sale), 11)
})

# Test 2: Check the number of rows
test_that("avocado_us_sale has 810 rows", {
  expect_equal(nrow(avocado_us_sale), 810)
})

# Test 3: Validate column names
test_that("avocado_us_sale has correct column names", {
  expect_named(
    avocado_us_sale,
    c("week_ending", "type", "avg_selling_price", "total_bulk_and_bags_units",
      "plu4046_units", "plu4225_units", "plu4770_units", "total_bagged_units",
      "sml_bagged_units", "lrg_bagged_units", "xlrg_bagged_units")
  )
})

# Test 4: Check data types
test_that("avocado_us_sale has correct data types", {
  expect_s3_class(avocado_us_sale$week_ending, "Date")
  expect_type(avocado_us_sale$type, "character")
  expect_type(avocado_us_sale$avg_selling_price, "double")
  expect_type(avocado_us_sale$total_bulk_and_bags_units, "double")
  expect_type(avocado_us_sale$plu4046_units, "double")
  expect_type(avocado_us_sale$plu4225_units, "double")
  expect_type(avocado_us_sale$plu4770_units, "double")
  expect_type(avocado_us_sale$total_bagged_units, "double")
  expect_type(avocado_us_sale$sml_bagged_units, "double")
  expect_type(avocado_us_sale$lrg_bagged_units, "double")
  expect_type(avocado_us_sale$xlrg_bagged_units, "double")
})
