test_that("estimate_ps returns data.frame with PS column", { result <- estimate_ps( in_df = small_df, exposure_var = "exposure", class_vars = class_vars, cont_vars = cont_vars, ps_var = "ps", verbose = FALSE ) expect_s3_class(result, "data.frame") expect_true("ps" %in% names(result)) expect_equal(nrow(result), nrow(small_df)) expect_true(all(result$ps >= 0 & result$ps <= 1)) }) test_that("estimate_ps errors when no data provided", { expect_error( estimate_ps(in_df = NULL, in_csvpath = NULL, verbose = FALSE), "Either in_df or in_csvpath" ) }) test_that("estimate_ps warns when both in_df and in_csvpath given", { expect_warning( estimate_ps( in_df = small_df, in_csvpath = sample_csv, exposure_var = "exposure", class_vars = class_vars, cont_vars = cont_vars, verbose = FALSE ), "Both in_df and in_csvpath" ) }) test_that("estimate_ps custom ps_var name works", { result <- estimate_ps( in_df = small_df, exposure_var = "exposure", class_vars = class_vars, cont_vars = cont_vars, ps_var = "my_ps", verbose = FALSE ) expect_true("my_ps" %in% names(result)) })