Skip to content

Commit 5f36bbe

Browse files
committed
Add tests for snapshots with different extensions.
1 parent 654e9fd commit 5f36bbe

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/testthat/_snaps/snapshot-manage.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@
3838
Updating snapshots:
3939
* test/a.txt
4040

41+
---
42+
43+
Code
44+
snapshot_accept("a", path = path)
45+
Message
46+
Updating snapshots:
47+
* a.md
48+
49+
---
50+
51+
Code
52+
snapshot_accept("test/", path = path)
53+
Message
54+
Updating snapshots:
55+
* test/a.md
56+
* test/b.txt
57+
4158
# can work with variants
4259

4360
Code

tests/testthat/test-snapshot-manage.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ test_that("can accept specific files", {
2121
expect_snapshot(snapshot_accept("test/", path = path))
2222
expect_equal(dir(file.path(path, "_snaps"), recursive = TRUE), "test/a.txt")
2323

24+
# snapshot files with different extensions
25+
path <- local_snapshot_dir(c("a.md", "a.new.md", "b.txt", "b.new.txt"))
26+
expect_snapshot(snapshot_accept("a", path = path))
27+
expect_equal(dir(file.path(path, "_snaps")), c("a.md", "b.new.txt", "b.txt"))
28+
29+
path <- local_snapshot_dir(c("test/a.md", "test/a.new.md",
30+
"test/b.txt", "test/b.new.txt"))
31+
expect_snapshot(snapshot_accept("test/", path = path))
32+
expect_equal(dir(file.path(path, "_snaps"), recursive = TRUE), c("test/a.md", "test/b.txt"))
2433
})
2534

2635
test_that("can work with variants", {

0 commit comments

Comments
 (0)