@@ -12,6 +12,29 @@ test_that("fails if can't find tests", {
1212 })
1313})
1414
15+ test_that(" find_test_file() works with snapshot files" , {
16+ dir <- local_package_create()
17+ withr :: local_dir(dir )
18+ dir_create(" tests/testthat/_snaps" )
19+ file_create(" tests/testthat/test-foo.R" )
20+ file_create(" tests/testthat/_snaps/foo.md" )
21+
22+ path <- find_test_file(" tests/testthat/_snaps/foo.md" )
23+ expect_equal(path_file(path ), " test-foo.R" )
24+ })
25+
26+ test_that(" find_test_file() works with snapshot variant files" , {
27+ dir <- local_package_create()
28+
29+ withr :: local_dir(dir )
30+ dir_create(" tests/testthat/_snaps/variant" )
31+ file_create(" tests/testthat/test-foo.R" )
32+ file_create(" tests/testthat/_snaps/variant/foo.md" )
33+
34+ path <- find_test_file(" tests/testthat/_snaps/variant/foo.md" )
35+ expect_equal(path_file(path ), " test-foo.R" )
36+ })
37+
1538test_that(" can determine file type" , {
1639 expect_equal(test_file_type(" R/foo.R" ), " R" )
1740 expect_equal(test_file_type(" R/foo.c" ), NA_character_ )
@@ -23,5 +46,9 @@ test_that("can determine file type", {
2346 expect_equal(test_file_type(" tests/testthat/test-foo.c" ), NA_character_ )
2447 expect_equal(test_file_type(" tests/testthat/foo.R" ), NA_character_ )
2548
49+ expect_equal(test_file_type(" tests/testthat/_snaps/foo.md" ), " snap" )
50+ expect_equal(test_file_type(" tests/testthat/_snaps/variant/foo.md" ), " snap" )
51+ expect_equal(test_file_type(" tests/testthat/_snaps/foo.R" ), NA_character_ )
52+
2653 expect_equal(test_file_type(" DESCRIPTION" ), NA_character_ )
2754})
0 commit comments