Skip to content

Commit

Permalink
Address PR feedback from @AnthonyMDev
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesonwilliams committed Mar 22, 2024
1 parent 2a1ab11 commit e31d708
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 4 additions & 16 deletions Tests/ApolloTests/Cache/StoreSubscriptionTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Nimble
import XCTest
@testable import Apollo

Expand Down Expand Up @@ -38,27 +39,14 @@ class StoreSubscriptionTests: XCTestCase {
wait(for: [cacheKeyChangeExpectation], timeout: Self.defaultWaitTimeout)
}

func testUnsubscribedSubscriberDoesNotReceiveStoreUpdate() throws {
let cacheKeyChangeExpectation = XCTestExpectation(description: "Subscriber is notified of cache key change")
cacheKeyChangeExpectation.isInverted = true

let expectedChangeKeySet: Set<String> = ["QUERY_ROOT.__typename", "QUERY_ROOT.name"]
let subscriber = SimpleSubscriber(cacheKeyChangeExpectation, expectedChangeKeySet)
func testUnsubscribeRemovesSubscriberFromApolloStore() throws {
let subscriber = SimpleSubscriber(XCTestExpectation(), [])

store.subscribe(subscriber)

store.unsubscribe(subscriber)

store.publish(
records: [
"QUERY_ROOT": [
"__typename": "Hero",
"name": "Han Solo"
]
]
)

wait(for: [cacheKeyChangeExpectation], timeout: Self.defaultWaitTimeout)
expect(self.store.subscribers).toEventually(beEmpty())
}

/// Fufills the provided expectation when all expected keys have been observed.
Expand Down
2 changes: 1 addition & 1 deletion apollo-ios/Sources/Apollo/ApolloStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ApolloStore {
private let cache: NormalizedCache
private let queue: DispatchQueue

private var subscribers: [ApolloStoreSubscriber] = []
internal var subscribers: [ApolloStoreSubscriber] = []

/// Designated initializer
/// - Parameters:
Expand Down

0 comments on commit e31d708

Please sign in to comment.