-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppFeatureTests.swift
More file actions
53 lines (47 loc) · 1.58 KB
/
AppFeatureTests.swift
File metadata and controls
53 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import ComposableArchitecture
import XCTest
@testable import Storefront
@MainActor
final class AppFeatureTests: XCTestCase {
func testOpenButtonPresentsFileImporter() async {
let store = TestStore(initialState: AppFeature.State()) {
AppFeature()
}
await store.send(.openButtonTapped) {
$0.isFileImporterPresented = true
}
}
func testFileImportedAppendsTab() async {
let url = URL(fileURLWithPath: "/tmp/sample.sqlite")
let store = TestStore(
initialState: AppFeature.State(isFileImporterPresented: true)
) {
AppFeature()
} withDependencies: {
$0.uuid = .incrementing
}
store.exhaustivity = .off
let expectedID = UUID(uuidString: "00000000-0000-0000-0000-000000000000")!
await store.send(.fileImported(url)) {
$0.isFileImporterPresented = false
$0.tabs = [BrowserTab.State(id: expectedID, databaseURL: url)]
$0.selectedTabID = expectedID
}
}
func testCloseCurrentTabRemovesSelectedTab() async {
let url = URL(fileURLWithPath: "/tmp/sample.sqlite")
let id = UUID(uuidString: "00000000-0000-0000-0000-000000000001")!
let store = TestStore(
initialState: AppFeature.State(
tabs: [BrowserTab.State(id: id, databaseURL: url)],
selectedTabID: id
)
) {
AppFeature()
}
await store.send(.closeCurrentTab) {
$0.tabs = []
$0.selectedTabID = nil
}
}
}