From 2e22626a5b994182a5c4990d042de1c3f73e47b3 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 13 Feb 2025 02:44:02 -0800 Subject: feat: Initial commit --- TonboTests/TonboTests.swift | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 TonboTests/TonboTests.swift (limited to 'TonboTests/TonboTests.swift') diff --git a/TonboTests/TonboTests.swift b/TonboTests/TonboTests.swift new file mode 100644 index 0000000..a107f90 --- /dev/null +++ b/TonboTests/TonboTests.swift @@ -0,0 +1,31 @@ +import Testing +import Foundation +import Apollo +import Tonbo + +struct TonboTests { + private let apolloClient = ApolloClient(url: URL(string: "https://graphql.anilist.co")!) + + private func fetchUserID(completion: @escaping (Int) -> Void) { + apolloClient.fetch(query: UserIDQuery()) { result in + switch result { + case .success(let graphQLResult): + if let userID = graphQLResult.data?.user?.id { + completion(userID) + } else if let errors = graphQLResult.errors { + print(errors) + completion(-1) + } + case .failure(let error): + print(error) + completion(-2) + } + } + } + + @Test private func userIDQuery() async throws { + fetchUserID { userID in + #expect(userID == 5678223) + } + } +} -- cgit v1.2.3