summaryrefslogtreecommitdiff
path: root/TonboTests
diff options
context:
space:
mode:
Diffstat (limited to 'TonboTests')
-rw-r--r--TonboTests/TonboTests.swift31
1 files changed, 31 insertions, 0 deletions
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)
+ }
+ }
+}