-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dafdf21
commit ea63fe0
Showing
3 changed files
with
160 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletions
88
...pt1/CaseStudies/CaseStudies.xcodeproj/xcshareddata/xcschemes/CaseStudies (UIKit).xcscheme
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
0153-refreshable-pt1/CaseStudies/SwiftUICaseStudiesTests/RefreshableTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@testable import SwiftUICaseStudies | ||
import XCTest | ||
|
||
class RefreshableTests: XCTestCase { | ||
func testVanilla() async { | ||
let viewModel = PullToRefreshViewModel( | ||
fetch: { count in | ||
await Task.sleep(20_000_000) | ||
return "\(count) is a good number." | ||
} | ||
) | ||
|
||
viewModel.incrementButtonTapped() | ||
XCTAssertEqual(viewModel.count, 1) | ||
|
||
XCTAssertEqual(viewModel.isLoading, false) | ||
let task = Task { | ||
await viewModel.getFact() | ||
} | ||
await Task.sleep(10_000_000) | ||
XCTAssertEqual(viewModel.isLoading, true) | ||
await task.value | ||
XCTAssertEqual(viewModel.fact, "1 is a good number.") | ||
XCTAssertEqual(viewModel.isLoading, false) | ||
} | ||
} |