Skip to content

Instantly share code, notes, and snippets.

@atimca
Created July 8, 2020 16:23
Show Gist options
  • Save atimca/ce8499f5630ec52d40b770a7eba9e405 to your computer and use it in GitHub Desktop.
Save atimca/ce8499f5630ec52d40b770a7eba9e405 to your computer and use it in GitHub Desktop.
// User wants to open calendar event edit.
// User doesn't have permission for editing a calendar.
// Request should be sent to the user.
// If the user authorized the permission.
// Calendar event edit will be opened.
// User added new event. -> Calendar State should be saved. And then the scene should be dismissed with Calendar State == nil.
// After dismissing dismissedScene should be calendar.
func testCalendarUserStoryWithPermission() {
// Given
let authorizedEvents = [PermissionType.events: PermissionStatus.authorized]
let emptyPermissions: [PermissionType: PermissionStatus] = [:]
let calendarEvent = CalendarEvent.testEvent
// When
let result = TestStore(
scheduler: scheduler,
disposeBag: disposeBag,
permissionService: { .just(.authorized) }
)
.start(with: [.showScene(.calendar(event: calendarEvent)),
.userFinishedWithCalendarEditor(with: .saved)])
// Then
XCTAssertEqual(result[0].sceneForOpen, nil)
XCTAssertEqual(result[0].permissions, emptyPermissions)
XCTAssertEqual(result[1].sceneForOpen, .calendar(event: calendarEvent))
XCTAssertEqual(result[1].permissions, emptyPermissions)
XCTAssertEqual(result[2].sceneForOpen, .calendar(event: calendarEvent))
XCTAssertEqual(result[2].permissions, authorizedEvents)
XCTAssertEqual(result[3].sceneForOpen, nil)
XCTAssertEqual(result[3].permissions, authorizedEvents)
XCTAssertEqual(result[4].calendarState, .saved)
XCTAssertEqual(result[5].calendarState, nil)
XCTAssertEqual(result[5].dismissedScene, .calendar(result: .saved))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment