File tree Expand file tree Collapse file tree 3 files changed +35
-15
lines changed
__Snapshots__/AnyJSONTests Expand file tree Collapse file tree 3 files changed +35
-15
lines changed Original file line number Diff line number Diff 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 " ] ) ,
Original file line number Diff line number Diff line change 88@testable import _Helpers
99import CustomDump
1010import Foundation
11+ import SnapshotTesting
1112import XCTest
1213
1314final 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 number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments