-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for RoutableCollection utilities
- Loading branch information
1 parent
c4f332f
commit 8d1bc57
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
Tests/FlowStacksTests/FlowStacksTests.swift → ...FlowStacksTests/CalculateStepsTests.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
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,77 @@ | ||
@testable import FlowStacks | ||
import XCTest | ||
|
||
final class RoutableCollectionTests: XCTestCase { | ||
typealias RouterState = [Route<Int>] | ||
|
||
func testPopToCurrentNavigationRootPresented() { | ||
var routes: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.sheet(-1, embedInNavigationView: true), | ||
.push(-2), | ||
.push(-3), | ||
.push(-4) | ||
] | ||
|
||
routes.popToCurrentNavigationRoot() | ||
|
||
let expectedResult: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.sheet(-1, embedInNavigationView: true) | ||
] | ||
XCTAssertEqual(routes, expectedResult) | ||
} | ||
|
||
func testPopToCurrentNavigationRootNotPresented() { | ||
var routes: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.push(-2), | ||
.push(-3), | ||
.push(-4) | ||
] | ||
|
||
routes.popToCurrentNavigationRoot() | ||
|
||
let expectedResult: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
] | ||
XCTAssertEqual(routes, expectedResult) | ||
} | ||
|
||
func testDismissAll() { | ||
var routes: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.push(-2), | ||
.sheet(3, embedInNavigationView: true), | ||
.sheet(4, embedInNavigationView: true), | ||
.sheet(5, embedInNavigationView: true), | ||
.sheet(6, embedInNavigationView: true), | ||
.push(-4) | ||
] | ||
|
||
routes.dismissAll() | ||
|
||
let expectedResult: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.push(-2), | ||
] | ||
XCTAssertEqual(routes, expectedResult) | ||
} | ||
|
||
func testDismissAllNoOpWithOnlyPushes() { | ||
var routes: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.push(2), | ||
.push(3) | ||
] | ||
|
||
routes.dismissAll() | ||
|
||
let expectedResult: RouterState = [ | ||
.root(1, embedInNavigationView: true), | ||
.push(2), | ||
.push(3) | ||
] | ||
XCTAssertEqual(routes, expectedResult) | ||
} | ||
} |