Skip to content

Commit 07d8f99

Browse files
committed
wip
1 parent 4e0d91f commit 07d8f99

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

Package.swift

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ let package = Package(
6060
dependencies: [
6161
"_Helpers",
6262
.product(name: "CustomDump", package: "swift-custom-dump"),
63+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
6364
]
6465
),
6566
.target(name: "Functions", dependencies: ["_Helpers"]),

Tests/_HelpersTests/AnyJSONTests.swift

+3-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@testable import _Helpers
99
import CustomDump
1010
import Foundation
11+
import SnapshotTesting
1112
import XCTest
1213

1314
final class AnyJSONTests: XCTestCase {
@@ -63,21 +64,8 @@ final class AnyJSONTests: XCTestCase {
6364
],
6465
]
6566

66-
func testDecode() throws {
67-
let data = try XCTUnwrap(jsonString.data(using: .utf8))
68-
let decodedJSON = try AnyJSON.decoder.decode(AnyJSON.self, from: data)
69-
70-
XCTAssertNoDifference(decodedJSON, jsonObject)
71-
}
72-
73-
func testEncode() throws {
74-
let encoder = AnyJSON.encoder
75-
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
76-
77-
let data = try encoder.encode(jsonObject)
78-
let decodedJSONString = try XCTUnwrap(String(data: data, encoding: .utf8))
79-
80-
XCTAssertNoDifference(decodedJSONString, jsonString)
67+
func testCodable() throws {
68+
assertSnapshot(of: jsonObject, as: .json)
8169
}
8270

8371
func testInitFromCodable() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"array" : [
3+
1,
4+
2,
5+
3,
6+
4,
7+
5
8+
],
9+
"bool" : true,
10+
"double" : 3.14,
11+
"integer" : 1,
12+
"null" : null,
13+
"object" : {
14+
"array" : [
15+
1,
16+
2,
17+
3,
18+
4,
19+
5
20+
],
21+
"bool" : true,
22+
"double" : 3.14,
23+
"integer" : 1,
24+
"null" : null,
25+
"object" : {
26+
27+
},
28+
"string" : "A string value"
29+
},
30+
"string" : "A string value"
31+
}

0 commit comments

Comments
 (0)