Skip to content

Commit 2263a6c

Browse files
committed
Rename AtomTextContext/waitUntilNextUpdate to waitForUpdate
1 parent de6f057 commit 2263a6c

File tree

11 files changed

+36
-36
lines changed

11 files changed

+36
-36
lines changed

Examples/Packages/iOS/Tests/ExampleMapTests/ExampleMapTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ final class ExampleMapTests: XCTestCase {
6060
observer.objectWillChange.send()
6161
}
6262

63-
await context.waitUntilNextUpdate()
63+
await context.waitForUpdate()
6464

6565
XCTAssertEqual(context.watch(atom), .authorizedAlways)
6666

6767
observer.objectWillChange.send()
68-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
68+
let didUpdate = await context.waitForUpdate(timeout: 1)
6969

7070
// Should not update if authorizationStatus is not changed.
7171
XCTAssertFalse(didUpdate)

Examples/Packages/iOS/Tests/ExampleVoiceMemoTests/ExampleVoiceMemoTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class ExampleVoiceMemoTests: XCTestCase {
6565

6666
XCTAssertEqual(context.watch(atom), .suspending)
6767

68-
await context.waitUntilNextUpdate()
68+
await context.waitForUpdate()
6969

7070
XCTAssertEqual(context.watch(atom), .success(.zero))
7171

@@ -74,7 +74,7 @@ final class ExampleVoiceMemoTests: XCTestCase {
7474

7575
XCTAssertEqual(context.watch(atom), .suspending)
7676

77-
await context.waitUntilNextUpdate()
77+
await context.waitForUpdate()
7878

7979
XCTAssertEqual(context.watch(atom), .success(10))
8080
}
@@ -178,7 +178,7 @@ final class ExampleVoiceMemoTests: XCTestCase {
178178

179179
XCTAssertEqual(context.watch(atom), .suspending)
180180

181-
await context.waitUntilNextUpdate()
181+
await context.waitForUpdate()
182182

183183
XCTAssertEqual(context.watch(atom), .success(.zero))
184184

@@ -187,7 +187,7 @@ final class ExampleVoiceMemoTests: XCTestCase {
187187

188188
XCTAssertEqual(context.watch(atom), .suspending)
189189

190-
await context.waitUntilNextUpdate()
190+
await context.waitForUpdate()
191191

192192
XCTAssertEqual(context.watch(atom), .success(10))
193193
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ A context that can simulate any scenarios in which atoms are used from a view or
11091109
|:--|:--|
11101110
|[unwatch(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/unwatch(_:))|Simulates a scenario in which the atom is no longer watched.|
11111111
|[override(_:with:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/override(_:with:)-1ce4h)|Overwrites the output of a specific atom or all atoms of the given type with the fixed value.|
1112-
|[waitUntilNextUpdate(timeout:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/waituntilnextupdate(timeout:))|Waits until any of atoms watched through this context is updated.|
1112+
|[waitForUpdate(timeout:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/waitforupdate(timeout:))|Waits until any of atoms watched through this context is updated.|
11131113
|[onUpdate](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/onupdate)|Sets a closure that notifies there has been an update to one of the atoms.|
11141114

11151115
---

Sources/Atoms/Context/AtomTestContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct AtomTestContext: AtomWatchableContext {
3333
/// let initialPhase = context.watch(AsyncCalculationAtom().phase)
3434
/// XCTAssertEqual(initialPhase, .suspending)
3535
///
36-
/// let didUpdate = await context.waitUntilNextUpdate()
36+
/// let didUpdate = await context.waitForUpdate()
3737
/// let currentPhase = context.watch(AsyncCalculationAtom().phase)
3838
///
3939
/// XCTAssertTure(didUpdate)
@@ -45,7 +45,7 @@ public struct AtomTestContext: AtomWatchableContext {
4545
/// the next update. The default timeout interval is `60`.
4646
/// - Returns: A boolean value indicating whether an update is done.
4747
@discardableResult
48-
public func waitUntilNextUpdate(timeout interval: TimeInterval = 60) async -> Bool {
48+
public func waitForUpdate(timeout interval: TimeInterval = 60) async -> Bool {
4949
let updates = AsyncStream<Void> { continuation in
5050
let cancellable = state.notifier.sink(
5151
receiveCompletion: { completion in

Tests/AtomsTests/Atom/AsyncSequenceAtomTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ final class AsyncSequenceAtomTests: XCTestCase {
1616
do {
1717
// Value
1818
pipe.continuation.yield(0)
19-
await context.waitUntilNextUpdate()
19+
await context.waitForUpdate()
2020

2121
XCTAssertEqual(context.watch(atom).value, 0)
2222
}
2323

2424
do {
2525
// Failure
2626
pipe.continuation.finish(throwing: URLError(.badURL))
27-
await context.waitUntilNextUpdate()
27+
await context.waitForUpdate()
2828

2929
XCTAssertEqual(context.watch(atom).error as? URLError, URLError(.badURL))
3030
}
3131

3232
do {
3333
// Yield value after finish
3434
pipe.continuation.yield(1)
35-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
35+
let didUpdate = await context.waitForUpdate(timeout: 1)
3636

3737
XCTAssertFalse(didUpdate)
3838
}
@@ -43,7 +43,7 @@ final class AsyncSequenceAtomTests: XCTestCase {
4343
context.unwatch(atom)
4444

4545
pipe.continuation.yield(0)
46-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
46+
let didUpdate = await context.waitForUpdate(timeout: 1)
4747

4848
XCTAssertFalse(didUpdate)
4949
}
@@ -54,7 +54,7 @@ final class AsyncSequenceAtomTests: XCTestCase {
5454
context.unwatch(atom)
5555

5656
pipe.continuation.finish(throwing: URLError(.badURL))
57-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
57+
let didUpdate = await context.waitForUpdate(timeout: 1)
5858

5959
XCTAssertFalse(didUpdate)
6060
}
@@ -144,13 +144,13 @@ final class AsyncSequenceAtomTests: XCTestCase {
144144
XCTAssertTrue(updatedValues.isEmpty)
145145

146146
pipe.continuation.yield(0)
147-
await context.waitUntilNextUpdate()
147+
await context.waitForUpdate()
148148

149149
pipe.continuation.yield(1)
150-
await context.waitUntilNextUpdate()
150+
await context.waitForUpdate()
151151

152152
pipe.continuation.yield(2)
153-
await context.waitUntilNextUpdate()
153+
await context.waitForUpdate()
154154

155155
XCTAssertEqual(
156156
updatedValues,

Tests/AtomsTests/Atom/ModifiedAtomTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ModifiedAtomTests: XCTestCase {
3434
context[base] = "testtest"
3535
}
3636

37-
await context.waitUntilNextUpdate()
37+
await context.waitForUpdate()
3838
XCTAssertEqual(context.watch(atom), 8)
3939
}
4040

Tests/AtomsTests/Atom/ObservableObjectAtomTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final class ObservableObjectAtomTests: XCTestCase {
5151
}
5252

5353
object.update()
54-
await context.waitUntilNextUpdate()
54+
await context.waitForUpdate()
5555

5656
XCTAssertEqual(snapshot, 1)
5757
}
@@ -68,7 +68,7 @@ final class ObservableObjectAtomTests: XCTestCase {
6868
}
6969

7070
object.update()
71-
await context.waitUntilNextUpdate()
71+
await context.waitForUpdate()
7272

7373
XCTAssertEqual(updateCount, 1)
7474
}
@@ -86,7 +86,7 @@ final class ObservableObjectAtomTests: XCTestCase {
8686
updateCount = object.updatedCount
8787
}
8888
object.update()
89-
await context.waitUntilNextUpdate()
89+
await context.waitForUpdate()
9090

9191
XCTAssertTrue(object === overrideObject)
9292
XCTAssertEqual(updateCount, 1)
@@ -105,7 +105,7 @@ final class ObservableObjectAtomTests: XCTestCase {
105105
updateCount = object.updatedCount
106106
}
107107
object.update()
108-
await context.waitUntilNextUpdate()
108+
await context.waitForUpdate()
109109

110110
XCTAssertTrue(object === overrideObject)
111111
XCTAssertEqual(updateCount, 1)
@@ -123,7 +123,7 @@ final class ObservableObjectAtomTests: XCTestCase {
123123
XCTAssertTrue(updatedObjects.isEmpty)
124124
object.update()
125125

126-
await context.waitUntilNextUpdate()
126+
await context.waitForUpdate()
127127

128128
XCTAssertEqual(updatedObjects.last?.updatedCount, 1)
129129
}

Tests/AtomsTests/Atom/PublisherAtomTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ final class PublisherAtomTests: XCTestCase {
2020
// Value
2121
subject.send(0)
2222

23-
await context.waitUntilNextUpdate()
23+
await context.waitForUpdate()
2424
XCTAssertEqual(context.watch(atom), .success(0))
2525
}
2626

2727
do {
2828
// Error
2929
subject.send(completion: .failure(URLError(.badURL)))
3030

31-
await context.waitUntilNextUpdate()
31+
await context.waitForUpdate()
3232
XCTAssertEqual(context.watch(atom), .failure(URLError(.badURL)))
3333
}
3434

3535
do {
3636
// Send value after completion
3737
subject.send(1)
3838

39-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
39+
let didUpdate = await context.waitForUpdate(timeout: 1)
4040
XCTAssertFalse(didUpdate)
4141
}
4242

@@ -45,7 +45,7 @@ final class PublisherAtomTests: XCTestCase {
4545
context.unwatch(atom)
4646
subject.send(0)
4747

48-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
48+
let didUpdate = await context.waitForUpdate(timeout: 1)
4949
XCTAssertFalse(didUpdate)
5050
}
5151

@@ -54,7 +54,7 @@ final class PublisherAtomTests: XCTestCase {
5454
context.unwatch(atom)
5555
subject.send(completion: .failure(URLError(.badURL)))
5656

57-
let didUpdate = await context.waitUntilNextUpdate(timeout: 1)
57+
let didUpdate = await context.waitForUpdate(timeout: 1)
5858
XCTAssertFalse(didUpdate)
5959
}
6060

@@ -143,13 +143,13 @@ final class PublisherAtomTests: XCTestCase {
143143
XCTAssertTrue(updatedValues.isEmpty)
144144

145145
subject.send(0)
146-
await context.waitUntilNextUpdate()
146+
await context.waitForUpdate()
147147

148148
subject.send(1)
149-
await context.waitUntilNextUpdate()
149+
await context.waitForUpdate()
150150

151151
subject.send(2)
152-
await context.waitUntilNextUpdate()
152+
await context.waitForUpdate()
153153

154154
XCTAssertEqual(
155155
updatedValues,

Tests/AtomsTests/Atom/StateAtomTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final class StateAtomTests: XCTestCase {
7575
context[Dependency1Atom()] = 0
7676
}
7777

78-
await context.waitUntilNextUpdate()
78+
await context.waitForUpdate()
7979

8080
let value2 = context.watch(TestAtom())
8181
XCTAssertEqual(value2, 0)

Tests/AtomsTests/Context/AtomTestContextTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class AtomTestContextTests: XCTestCase {
3131
XCTAssertTrue(isCalled)
3232
}
3333

34-
func testWaitUntilNextUpdate() async {
34+
func testWaitForUpdate() async {
3535
let atom = TestStateAtom(defaultValue: 0)
3636
let context = AtomTestContext()
3737

@@ -41,11 +41,11 @@ final class AtomTestContextTests: XCTestCase {
4141
context[atom] = 1
4242
}
4343

44-
let didUpdate0 = await context.waitUntilNextUpdate()
44+
let didUpdate0 = await context.waitForUpdate()
4545

4646
XCTAssertTrue(didUpdate0)
4747

48-
let didUpdate1 = await context.waitUntilNextUpdate(timeout: 1)
48+
let didUpdate1 = await context.waitForUpdate(timeout: 1)
4949

5050
XCTAssertFalse(didUpdate1)
5151
}

0 commit comments

Comments
 (0)