Skip to content

Instantly share code, notes, and snippets.

@esilverberg
Last active November 24, 2020 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esilverberg/398d90806a35081df9bd0de87374e9e7 to your computer and use it in GitHub Desktop.
Save esilverberg/398d90806a35081df9bd0de87374e9e7 to your computer and use it in GitHub Desktop.
context("given instruction cards should be shown") {
var testObs: TestObserver<PSSMatchViewModel.Event, Never>!
beforeEach {
testObs = TestObserver<PSSMatchViewModel.Event, Never>()
viewModel.events.signal.observe(testObs.observer)
}
it("then swipe right card shown first") {
guard case .started(let context) = viewModel.state.value else {
XCTFail("Invalid state")
return
}
guard case .instructions(let rating) = context.cards.first else {
XCTFail("Invalid card")
return
}
expect(rating).to(equal(PSSMatchRating.interested))
}
context("when swiping past first") {
beforeEach {
viewModel.swipe(rating: .interested)
}
it("then app event is recorded") {
expect((appEventLogger as! AppEventLoggerFixture).lastEvent).to(beAppEventLoggable(PSSMatchAppEvent.swipedInstructions(instructionRating: .interested, actualRating: .interested)))
}
it("then swipe left shown next") {
guard case .started(let context) = viewModel.state.value else {
XCTFail("Invalid state")
return
}
guard case .instructions(let rating) = context.cards.first else {
XCTFail("Invalid card")
return
}
expect(rating).to(equal(PSSMatchRating.notInterested))
}
<snip/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment