Skip to content

Commit 5fc1798

Browse files
committed
Navigator basic tests
1 parent b84f736 commit 5fc1798

File tree

2 files changed

+65
-49
lines changed

2 files changed

+65
-49
lines changed

Tests/NavigatorTests/NavigatorTests.swift renamed to Tests/NavigatorTests/NavigatorCoreTests.swift

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NavigatorTests.swift
2+
// NavigatorCoreTests.swift
33
// Navigator
44
//
55
// Created by zzmasoud on 02/15/25.
@@ -9,7 +9,8 @@ import Testing
99
import Foundation
1010
@testable import Navigator
1111

12-
struct NavigatorTests {
12+
struct NavigatorCoreTests {
13+
1314
// MARK: - Basic Navigation State Tests
1415

1516
@Test func testNavigatorInitialization() {
@@ -35,53 +36,6 @@ struct NavigatorTests {
3536
#expect(childNavigator.state.isPresented)
3637
}
3738

38-
// MARK: - Navigation Path Management
39-
40-
@Test func testNavigationPathOperations() async {
41-
let navigator = Navigator(owner: .root)
42-
let destination = MockDestination.screen1
43-
44-
// Test push
45-
await navigator.push(destination)
46-
#expect(navigator.state.path.count == 1)
47-
48-
// Test pop
49-
let popped = await navigator.pop()
50-
#expect(popped)
51-
#expect(navigator.state.path.isEmpty)
52-
}
53-
54-
@Test func testMultiplePathOperations() async {
55-
let navigator = Navigator(owner: .root)
56-
57-
// Push multiple destinations
58-
await navigator.push(MockDestination.screen1)
59-
await navigator.push(MockDestination.screen2)
60-
await navigator.push(MockDestination.screen3)
61-
#expect(navigator.state.path.count == 3)
62-
63-
// Pop to root
64-
let popped = await navigator.popAll()
65-
#expect(popped)
66-
#expect(navigator.state.path.isEmpty)
67-
}
68-
69-
// MARK: - Sheet Presentation Tests
70-
71-
@Test func testSheetPresentation() async {
72-
let navigator = Navigator(owner: .root)
73-
let destination = MockDestination.screen1
74-
75-
// Present sheet
76-
await navigator.navigate(to: destination, method: .sheet)
77-
#expect(navigator.state.sheet != nil)
78-
#expect(navigator.state.sheet?.wrapped as? MockDestination == destination)
79-
80-
// Dismiss sheet
81-
await navigator.dismissPresentedViews()
82-
#expect(navigator.state.sheet == nil)
83-
}
84-
8539
// MARK: - Navigation Lock Tests
8640

8741
@Test func testNavigationLocking() async {
@@ -121,4 +75,5 @@ struct NavigatorTests {
12175
parent.state.removeChild(child1)
12276
#expect(parent.state.children.count == 1)
12377
}
78+
12479
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// NavigatorOperationTests.swift
3+
// Navigator
4+
//
5+
// Created by hmlong on 02/20/25.
6+
//
7+
8+
import Testing
9+
import Foundation
10+
@testable import Navigator
11+
12+
struct NavigatorOperationTests {
13+
14+
// MARK: - Navigation Path Management
15+
16+
@Test func testNavigationPathOperations() async {
17+
let navigator = Navigator(owner: .root)
18+
let destination = MockDestination.screen1
19+
20+
// Test push
21+
await navigator.push(destination)
22+
#expect(navigator.state.path.count == 1)
23+
24+
// Test pop
25+
let popped = await navigator.pop()
26+
#expect(popped)
27+
#expect(navigator.state.path.isEmpty)
28+
}
29+
30+
@Test func testMultiplePathOperations() async {
31+
let navigator = Navigator(owner: .root)
32+
33+
// Push multiple destinations
34+
await navigator.push(MockDestination.screen1)
35+
await navigator.push(MockDestination.screen2)
36+
await navigator.push(MockDestination.screen3)
37+
#expect(navigator.state.path.count == 3)
38+
39+
// Pop to root
40+
let popped = await navigator.popAll()
41+
#expect(popped)
42+
#expect(navigator.state.path.isEmpty)
43+
}
44+
45+
// MARK: - Sheet Presentation Tests
46+
47+
@Test func testSheetPresentation() async {
48+
let navigator = Navigator(owner: .root)
49+
let destination = MockDestination.screen1
50+
51+
// Present sheet
52+
await navigator.navigate(to: destination, method: .sheet)
53+
#expect(navigator.state.sheet != nil)
54+
#expect(navigator.state.sheet?.wrapped as? MockDestination == destination)
55+
56+
// Dismiss sheet
57+
await navigator.dismissPresentedViews()
58+
#expect(navigator.state.sheet == nil)
59+
}
60+
61+
}

0 commit comments

Comments
 (0)