Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding wait failed
  • Loading branch information
obj-p committed May 18, 2019
commit 8618792aeeaefe8e6c869b3517adedadb2bffa68
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ store.dispatch(thunkWithParams(10))

## Testing

The `ExpectThunk` helper, available as a CocoaPods subspec, allows for testing the order and actions of `dispatch` as well as the dependencies on `getState` in a thunk.
The `ExpectThunk` helper, available as a CocoaPods subspec, allows for testing the order and actions of `dispatch` as well as the dependencies on `getState` in a thunk.

```swift
ExpectThunk(thunk)
Expand Down
12 changes: 9 additions & 3 deletions ReSwift-ThunkTests/ExpectThunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension ExpectThunk {
ExpectThunkAssertion(file: file, line: line) { received in
XCTAssert(
received as? A == expected,
"dispatched action does not equal expected: \(received) \(expected)",
"Dispatched action does not equal expected: \(received) \(expected)",
file: file,
line: line
)
Expand Down Expand Up @@ -102,10 +102,16 @@ extension ExpectThunk {
}

@discardableResult
public func wait(timeout seconds: TimeInterval = 1, description: String = "\(ExpectThunk.self)") -> Self {
public func wait(timeout seconds: TimeInterval = 1,
file: StaticString = #file,
line: UInt = #line,
description: String = "\(ExpectThunk.self)") -> Self {
let expectation = XCTestExpectation(description: description)
defer {
let waiter = XCTWaiter().wait(for: [expectation], timeout: seconds)
let result = XCTWaiter().wait(for: [expectation], timeout: seconds)
if result != .completed {
XCTFail("Asynchronous wait failed", file: file, line: line)
}
failLeftovers()
}
let dispatch: DispatchFunction = {
Expand Down