Skip to content

Commit 9f2a0c8

Browse files
committed
fix: use local level parsing.
1 parent dc47e63 commit 9f2a0c8

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

tests/languages/apple/Tests.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ class Tests: XCTestCase {
2525
.addHeader(key: "Origin", value: "http://localhost")
2626
.setSelfSigned()
2727

28-
var mock: Mock
29-
3028
// Ping pong test
3129
let ping = try await client.ping()
32-
mock = Mock.from(json: ping)!
33-
print(mock.result)
30+
let pingResult = parse(from: ping)!
31+
print(pingResult)
3432

3533
// reset configs
3634
client.setProject("console")
@@ -48,7 +46,9 @@ class Tests: XCTestCase {
4846
realtimeResponse = message.payload!["response"] as! String
4947
expectation.fulfill()
5048
}
51-
49+
50+
var mock: Mock
51+
5252
// Foo Tests
5353
mock = try await foo.get(x: "string", y: 123, z: ["string in array"])
5454
print(mock.result)
@@ -206,4 +206,13 @@ class Tests: XCTestCase {
206206
mock = try await general.headers()
207207
print(mock.result)
208208
}
209+
210+
func parse(from json: String) -> String? {
211+
if let data = json.data(using: .utf8),
212+
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
213+
let result = jsonObject["result"] as? String {
214+
return result
215+
}
216+
return nil
217+
}
209218
}

tests/languages/swift/Tests.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ class Tests: XCTestCase {
2525
.addHeader(key: "Origin", value: "http://localhost")
2626
.setSelfSigned()
2727

28-
var mock: Mock
29-
3028
// Ping pong test
3129
let ping = try await client.ping()
32-
mock = Mock.from(json: ping)!
33-
print(mock.result)
30+
let pingResult = parse(from: ping)!
31+
print(pingResult)
3432

3533
// reset project
3634
client.setProject("console")
@@ -39,6 +37,8 @@ class Tests: XCTestCase {
3937
let bar = Bar(client)
4038
let general = General(client)
4139

40+
var mock: Mock
41+
4242
// Foo Tests
4343
mock = try await foo.get(x: "string", y: 123, z: ["string in array"])
4444
print(mock.result)
@@ -197,4 +197,13 @@ class Tests: XCTestCase {
197197
print(error.localizedDescription)
198198
}
199199
}
200+
201+
func parse(from json: String) -> String? {
202+
if let data = json.data(using: .utf8),
203+
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
204+
let result = jsonObject["result"] as? String {
205+
return result
206+
}
207+
return nil
208+
}
200209
}

0 commit comments

Comments
 (0)