forked from CodeEditApp/CodeEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeEditUITests.swift
More file actions
127 lines (108 loc) · 4.71 KB
/
CodeEditUITests.swift
File metadata and controls
127 lines (108 loc) · 4.71 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// UnitTests.swift
// CodeEditModules/CodeEditUITests
//
// Created by Lukas Pistrol on 19.04.22.
//
@testable import CodeEdit
import Foundation
import SnapshotTesting
import SwiftUI
import XCTest
final class CodeEditUIUnitTests: XCTestCase {
// MARK: Help Button
func testHelpButtonLight() throws {
let view = HelpButton(action: {})
let hosting = NSHostingView(rootView: view)
hosting.frame = CGRect(origin: .zero, size: .init(width: 40, height: 40))
hosting.appearance = .init(named: .aqua)
assertSnapshot(matching: hosting, as: .image(size: .init(width: 40, height: 40)))
}
func testHelpButtonDark() throws {
let view = HelpButton(action: {})
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 40, height: 40))
assertSnapshot(matching: hosting, as: .image)
}
// MARK: Segmented Control
func testSegmentedControlLight() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"])
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
func testSegmentedControlDark() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"])
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
func testSegmentedControlProminentLight() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"], prominent: true)
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
func testSegmentedControlProminentDark() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"], prominent: true)
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
// MARK: FontPickerView
func testFontPickerViewLight() throws {
let view = FontPicker("Font", name: .constant("SF-Mono"), size: .constant(13))
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 120, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
func testFontPickerViewDark() throws {
let view = FontPicker("Font", name: .constant("SF-Mono"), size: .constant(13))
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 120, height: 30))
assertSnapshot(matching: hosting, as: .image)
}
// MARK: EffectView
func testEffectViewLight() throws {
let view = EffectView()
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 20, height: 20))
assertSnapshot(matching: hosting, as: .image)
}
func testEffectViewDark() throws {
let view = EffectView()
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 20, height: 20))
assertSnapshot(matching: hosting, as: .image)
}
// MARK: ToolbarBranchPicker
func testBranchPickerLight() throws {
let view = ToolbarBranchPicker(
shellClient: ShellClient(),
workspace: nil
)
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 50))
assertSnapshot(matching: hosting, as: .image)
}
func testBranchPickerDark() throws {
let view = ToolbarBranchPicker(
shellClient: ShellClient(),
workspace: nil
)
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 50))
assertSnapshot(matching: hosting, as: .image)
}
}