Skip to content

Commit

Permalink
fix: use local level parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzNotABug committed Dec 12, 2024
1 parent dc47e63 commit 9f2a0c8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
19 changes: 14 additions & 5 deletions tests/languages/apple/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class Tests: XCTestCase {
.addHeader(key: "Origin", value: "http://localhost")
.setSelfSigned()

var mock: Mock

// Ping pong test
let ping = try await client.ping()
mock = Mock.from(json: ping)!
print(mock.result)
let pingResult = parse(from: ping)!
print(pingResult)

// reset configs
client.setProject("console")
Expand All @@ -48,7 +46,9 @@ class Tests: XCTestCase {
realtimeResponse = message.payload!["response"] as! String
expectation.fulfill()
}


var mock: Mock

// Foo Tests
mock = try await foo.get(x: "string", y: 123, z: ["string in array"])
print(mock.result)
Expand Down Expand Up @@ -206,4 +206,13 @@ class Tests: XCTestCase {
mock = try await general.headers()
print(mock.result)
}

func parse(from json: String) -> String? {
if let data = json.data(using: .utf8),
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let result = jsonObject["result"] as? String {
return result
}
return nil
}
}
17 changes: 13 additions & 4 deletions tests/languages/swift/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class Tests: XCTestCase {
.addHeader(key: "Origin", value: "http://localhost")
.setSelfSigned()

var mock: Mock

// Ping pong test
let ping = try await client.ping()
mock = Mock.from(json: ping)!
print(mock.result)
let pingResult = parse(from: ping)!
print(pingResult)

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

var mock: Mock

// Foo Tests
mock = try await foo.get(x: "string", y: 123, z: ["string in array"])
print(mock.result)
Expand Down Expand Up @@ -197,4 +197,13 @@ class Tests: XCTestCase {
print(error.localizedDescription)
}
}

func parse(from json: String) -> String? {
if let data = json.data(using: .utf8),
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let result = jsonObject["result"] as? String {
return result
}
return nil
}
}

0 comments on commit 9f2a0c8

Please sign in to comment.