-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLiteralHeadersSettingTests.swift
48 lines (41 loc) · 1.48 KB
/
LiteralHeadersSettingTests.swift
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
@testable import Coder_Desktop
import SwiftUI
import Testing
import ViewInspector
@MainActor
@Suite(.timeLimit(.minutes(1)))
struct LiteralHeadersSettingTests {
let vpn: MockVPNService
let sut: LiteralHeadersSection<MockVPNService>
let view: any View
init() {
vpn = MockVPNService()
sut = LiteralHeadersSection<MockVPNService>()
let store = UserDefaults(suiteName: #file)!
store.removePersistentDomain(forName: #file)
view = sut.environmentObject(vpn).environmentObject(AppState(persistent: false))
}
@Test
func testToggleDisabledWhenVPNEnabled() async throws {
vpn.state = .connected
try await ViewHosting.host(view) {
try await sut.inspection.inspect { view in
let toggle = try view.find(ViewType.Toggle.self)
#expect(toggle.isDisabled())
#expect(throws: Never.self) { try toggle.labelView().find(text: "HTTP Headers") }
}
}
}
@Test
func testToggleEnabledWhenVPNDisabled() async throws {
vpn.state = .disabled
try await ViewHosting.host(view) {
try await sut.inspection.inspect { view in
let toggle = try view.find(ViewType.Toggle.self)
#expect(!toggle.isDisabled())
#expect(throws: Never.self) { try toggle.labelView().find(text: "HTTP Headers") }
}
}
}
// TODO: More tests, ViewInspector cannot currently inspect Tables
}