Skip to content

Commit 44f3f0f

Browse files
committed
Refactors suffix creation in snapshot assertion
1 parent 5a9da98 commit 44f3f0f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Sources/TestingExtensions/SnapshotTestBase.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@ open class SnapshotTestBase: XCTestCase {
5151
let vc = UIHostingController(rootView: view)
5252
vc.overrideUserInterfaceStyle = uiStyle
5353

54-
let suffix: String
55-
switch uiStyle {
56-
case .unspecified:
57-
suffix = ""
58-
case .light:
59-
suffix = "-light"
60-
case .dark:
61-
suffix = "-dark"
62-
@unknown default:
63-
fatalError("Unhandled UIUserInterfaceStyle \(uiStyle)")
64-
}
65-
54+
let suffix: String = {
55+
switch uiStyle {
56+
case .unspecified:
57+
return ""
58+
case .light:
59+
return "-light"
60+
case .dark:
61+
return "-dark"
62+
@unknown default:
63+
fatalError("Unhandled UIUserInterfaceStyle \(uiStyle)")
64+
}
65+
}()
66+
6667
assertSnapshot(
6768
of: vc,
6869
as: .image(on: config.device, precision: imageDiffPrecision),

0 commit comments

Comments
 (0)