Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Iron-Ham committed Jul 24, 2024
1 parent 40ee780 commit 7248770
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ final class AsyncGraphQLQueryPagerCoordinatorTests: XCTestCase, CacheDependentTe
nextQuery.__variables = [
"id": "2001",
"first": 2,
"before": pageInfo.startCursor
"before": pageInfo.startCursor,
]
return nextQuery
}
Expand Down Expand Up @@ -214,7 +214,7 @@ final class AsyncGraphQLQueryPagerCoordinatorTests: XCTestCase, CacheDependentTe
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand Down
20 changes: 11 additions & 9 deletions Tests/ApolloPaginationTests/AsyncGraphQLQueryPagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
initialQuery.__variables = [
"id": "2001",
"first": 2,
"after": GraphQLNullable<String>.null
"after": GraphQLNullable<String>.null,
]
let pager = AsyncGraphQLQueryPager(
client: client,
Expand All @@ -44,7 +44,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": page.endCursor
"after": page.endCursor,
]
return nextQuery
case .previous:
Expand Down Expand Up @@ -82,7 +82,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
initialQuery.__variables = [
"id": "2001",
"first": 2,
"after": GraphQLNullable<String>.null
"after": GraphQLNullable<String>.null,
]
let pager = AsyncGraphQLQueryPager(
client: client,
Expand All @@ -100,7 +100,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": page.endCursor
"after": page.endCursor,
]
return nextQuery
case .previous:
Expand Down Expand Up @@ -143,7 +143,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
initialQuery.__variables = [
"id": "2001",
"first": 2,
"after": GraphQLNullable<String>.null
"after": GraphQLNullable<String>.null,
]
let pager = AsyncGraphQLQueryPager(
client: client,
Expand All @@ -161,7 +161,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": page.endCursor
"after": page.endCursor,
]
return nextQuery
case .previous:
Expand Down Expand Up @@ -199,7 +199,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
initialQuery.__variables = [
"id": "2001",
"first": 2,
"after": GraphQLNullable<String>.null
"after": GraphQLNullable<String>.null,
]
let pager = AsyncGraphQLQueryPager(
client: client,
Expand All @@ -217,7 +217,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": page.endCursor
"after": page.endCursor,
]
return nextQuery
case .previous:
Expand Down Expand Up @@ -368,6 +368,8 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
let successValue = try result.get()
XCTAssertFalse(successValue.errors.isEmpty)
XCTAssertEqual(successValue.initialPage?.hero.name, "R2-D2")
let canLoadNext = await pager.canLoadNext
XCTAssertTrue(canLoadNext)
subscription.cancel()
}

Expand Down Expand Up @@ -458,7 +460,7 @@ final class AsyncGraphQLQueryPagerTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand Down
16 changes: 8 additions & 8 deletions Tests/ApolloPaginationTests/BidirectionalPaginationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
"id": "2001",
"first": 1,
"after": pageInfo.endCursor,
"before": GraphQLNullable<String>.null
"before": GraphQLNullable<String>.null,
]
return nextQuery
case .previous:
Expand All @@ -78,7 +78,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
"id": "2001",
"first": 1,
"before": pageInfo.startCursor,
"after": GraphQLNullable<String>.null
"after": GraphQLNullable<String>.null,
]
return previousQuery
}
Expand All @@ -102,7 +102,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
subscription.cancel()
var result = try await XCTUnwrapping(await pager.currentValue)
results.append(result)
XCTAssertSuccessResult(result) { (output) in
XCTAssertSuccessResult(result) { output in
XCTAssertTrue(output.nextPages.isEmpty)
XCTAssertEqual(output.initialPage?.hero.friendsConnection.friends.count, 1)
XCTAssertEqual(output.initialPage?.hero.friendsConnection.totalCount, 3)
Expand All @@ -123,7 +123,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
result = try await XCTUnwrapping(await pager.currentValue)
results.append(result)

try XCTAssertSuccessResult(result) { (output) in
try XCTAssertSuccessResult(result) { output in
// Assert first page is unchanged
XCTAssertEqual(try? results.first?.get().initialPage, try? results.last?.get().initialPage)

Expand Down Expand Up @@ -155,7 +155,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
result = try await XCTUnwrapping(await pager.currentValue)
results.append(result)

try XCTAssertSuccessResult(result) { (output) in
try XCTAssertSuccessResult(result) { output in
// Assert first page is unchanged
XCTAssertEqual(try? results.first?.get().initialPage, try? results.last?.get().initialPage)

Expand Down Expand Up @@ -217,7 +217,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
subscription.cancel()
var result = try await XCTUnwrapping(await pager.pager.currentValue)
results.append(result)
XCTAssertSuccessResult(result) { (output) in
XCTAssertSuccessResult(result) { output in
XCTAssertTrue(output.nextPages.isEmpty)
XCTAssertEqual(output.initialPage?.hero.friendsConnection.friends.count, 1)
XCTAssertEqual(output.initialPage?.hero.friendsConnection.totalCount, 3)
Expand All @@ -238,7 +238,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
result = try await XCTUnwrapping(await pager.pager.currentValue)
results.append(result)

try XCTAssertSuccessResult(result) { (output) in
try XCTAssertSuccessResult(result) { output in
// Assert first page is unchanged
XCTAssertEqual(try? results.first?.get().initialPage, try? results.last?.get().initialPage)

Expand Down Expand Up @@ -266,7 +266,7 @@ final class BidirectionalPaginationTests: XCTestCase, CacheDependentTesting {
result = try await XCTUnwrapping(await pager.pager.currentValue)
results.append(result)

try XCTAssertSuccessResult(result) { (output) in
try XCTAssertSuccessResult(result) { output in
// Assert first page is unchanged
XCTAssertEqual(try? results.first?.get().initialPage, try? results.last?.get().initialPage)

Expand Down
4 changes: 2 additions & 2 deletions Tests/ApolloPaginationTests/ConcurrencyTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class ConcurrencyTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand Down Expand Up @@ -120,7 +120,7 @@ final class ConcurrencyTests: XCTestCase {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand Down
18 changes: 9 additions & 9 deletions Tests/ApolloPaginationTests/ForwardPaginationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class ForwardPaginationTests: XCTestCase, CacheDependentTesting {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": "Y3Vyc29yMg=="
"after": "Y3Vyc29yMg==",
]

let expectedVariables = Set(nextQuery.__variables?.values.compactMap { $0._jsonEncodableValue?._jsonValue } ?? [])
Expand Down Expand Up @@ -268,7 +268,7 @@ final class ForwardPaginationTests: XCTestCase, CacheDependentTesting {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand Down Expand Up @@ -305,7 +305,7 @@ final class ForwardPaginationTests: XCTestCase, CacheDependentTesting {
nextQuery.__variables = [
"id": "2001",
"first": 2,
"after": pageInfo.endCursor
"after": pageInfo.endCursor,
]
return nextQuery
}
Expand All @@ -321,32 +321,32 @@ private extension Mocks.Hero.FriendsQuery {
let pageInfo: [AnyHashable: AnyHashable] = [
"__typename": "PageInfo",
"endCursor": "Y3Vyc29yMg==",
"hasNextPage": true
"hasNextPage": true,
]
let friends: [[String: AnyHashable]] = [
[
"__typename": "Human",
"name": "Luke Skywalker",
"id": "1000"
"id": "1000",
],
[
"__typename": "Human",
"name": "Han Solo",
"id": "1002"
]
"id": "1002",
],
]
let friendsConnection: [String: AnyHashable] = [
"__typename": "FriendsConnection",
"totalCount": 3,
"friends": friends,
"pageInfo": pageInfo
"pageInfo": pageInfo,
]

let hero: [String: AnyHashable] = [
"__typename": "Droid",
"id": "2001",
"name": "R2-D2",
"friendsConnection": friendsConnection
"friendsConnection": friendsConnection,
]

let data: [String: AnyHashable] = [
Expand Down
Loading

0 comments on commit 7248770

Please sign in to comment.