Skip to content

Commit 926f371

Browse files
committed
Add JSON golden test example
1 parent a3b4074 commit 926f371

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

.scalafmt.conf

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
version = "3.7.17"
22

33
runner.dialect = scala212source3
4-
# rewrite.scala3.insertEndMarkerMinLines = 10
5-
# rewrite.scala3.removeOptionalBraces = true
6-
# rewrite.scala3.convertToNewSyntax = true
74
align.preset = more
85

9-
# fileOverride {
10-
# "glob:**.sbt" {
11-
# runner.dialect = scala212source3
12-
# }
6+
fileOverride {
7+
# "glob:**.sbt" {
8+
# runner.dialect = scala212source3
9+
# }
1310

14-
# "glob:**/project/**.*" {
15-
# runner.dialect = scala212source3
16-
# }
11+
# "glob:**/project/**.*" {
12+
# runner.dialect = scala212source3
13+
# }
1714

18-
# "glob:**/snapshots-sbt-plugin/**.*" {
19-
# runner.dialect = scala212source3
20-
# }
15+
# "glob:**/snapshots-sbt-plugin/**.*" {
16+
# runner.dialect = scala212source3
2117

22-
# "glob:**/snapshots-buildtime/**.*" {
23-
# runner.dialect = scala212source3
24-
# }
25-
# }
18+
"glob:**/scala-3/**.*" {
19+
runner.dialect = scala3
20+
rewrite.scala3.insertEndMarkerMinLines = 10
21+
rewrite.scala3.removeOptionalBraces = true
22+
rewrite.scala3.convertToNewSyntax = true
23+
}
24+
}

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ lazy val example = projectMatrix
7878
snapshotsPackageName := "example",
7979
snapshotsAddRuntimeDependency := false,
8080
snapshotsIntegrations += SnapshotIntegration.MUnit,
81+
libraryDependencies += "io.circe" %%% "circe-core" % "0.14.6",
8182
noPublish
8283
)
8384
.enablePlugins(SnapshotsPlugin)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Hello" : {
3+
"a" : 25,
4+
"b" : {
5+
"s" : "yo"
6+
}
7+
}
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import com.indoorvivants.snapshots.munit_integration.*
2+
import munit.*
3+
4+
import io.circe.*, io.circe.syntax.*
5+
6+
case class Test(s: String)
7+
enum MyStuff derives Codec.AsObject:
8+
case Hello(a: Int, b: Test)
9+
case Bla(x: Boolean)
10+
11+
class JsonGoldenTests extends FunSuite with MunitSnapshotsIntegration:
12+
test("json tests") {
13+
val obj = MyStuff.Hello(25, Test("yo"))
14+
assertSnapshot("json.codec", obj.asJson.spaces4)
15+
}

0 commit comments

Comments
 (0)