-
Notifications
You must be signed in to change notification settings - Fork 0
/
MovieDetailsViewTests.swift
47 lines (40 loc) · 1.33 KB
/
MovieDetailsViewTests.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
import SwiftUI
import SnapshotTesting
import XCTest
@testable import SampleProject
class MovieDetailsViewTests: XCTestCase {
func testView_iPhone_lightMode() {
assertIPhoneSnapshot(of: viewContainer())
}
func testView_iPhone_darkMode_ES() {
assertIPhoneSnapshot(of: viewContainer(locale: "es"), appearance: .dark)
}
func testView_iPhone_lightMode_dynamicType() {
assertIPhoneSnapshot(
of: viewContainer(),
extraTraits: { mutableTraits in
mutableTraits.preferredContentSizeCategory = .accessibilityExtraExtraLarge
}
)
}
func testView_iPad_lightMode_NB() {
assertIPadSnapshot(of: viewContainer(locale: "nb"))
}
func testView_fixedSize() {
assertFixedSizeSnapshot(of: viewContainer(), width: 393, height: 1200)
}
private func viewContainer(locale: String? = nil) -> UIViewController {
let view = NavigationStack {
MovieDetailsView(viewData: .previewValue())
.navigationBarTitleDisplayMode(.inline)
.lineSpacing(8)
}
return if let locale {
UIHostingController(
rootView: view.environment(\.locale, .init(identifier: locale))
)
} else {
UIHostingController(rootView: view)
}
}
}