Created
July 17, 2019 23:38
-
-
Save PaulWoodIII/22e4423291869707f4c2c551ef9f2196 to your computer and use it in GitHub Desktop.
TestSchedulers for Combine
This file contains hidden or 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
| import XCTest | |
| import Combine | |
| import Entwine | |
| import EntwineTest | |
| class EntwineTestSchedulerExampleTests: XCTestCase { | |
| func testSchedulerInjection() { | |
| let scheduler = TestScheduler(initialClock: 0) | |
| var didSink = false | |
| let sut = Just<Void>(()) | |
| // Inject the scheduler as a Dependency to your system under test | |
| .delay(for: 1, scheduler: scheduler) | |
| .sink { _ in | |
| didSink = true | |
| } | |
| scheduler.resume() | |
| XCTAssertTrue(didSink) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment