File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed
Sources/TestingExtensions Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -32,20 +32,36 @@ open class SnapshotTestBase: XCTestCase {
3232 open func assertSnapshotDevices< V: View > (
3333 _ view: V ,
3434 devices: [ ( name: String , device: ViewImageConfig ) ] ? = nil ,
35+ style: [ UIUserInterfaceStyle ] = [ . unspecified] ,
3536 file: StaticString = #file,
3637 testName: String = #function,
3738 line: UInt = #line
3839 ) {
39- ( devices ?? defaultDevices) . forEach {
40- let vc = UIHostingController ( rootView: view)
40+ ( devices ?? defaultDevices) . forEach { config in
41+ style. forEach { uiStyle in
42+ let vc = UIHostingController ( rootView: view)
43+ vc. overrideUserInterfaceStyle = uiStyle
4144
42- assertSnapshot (
43- matching: vc,
44- as: . image( on: $0. device) ,
45- file: file,
46- testName: " \( testName) - \( $0. name) " ,
47- line: line
48- )
45+ let suffix : String
46+ switch uiStyle {
47+ case . unspecified:
48+ suffix = " "
49+ case . light:
50+ suffix = " -light "
51+ case . dark:
52+ suffix = " -dark "
53+ @unknown default :
54+ fatalError ( " Unhandled UIUserInterfaceStyle \( uiStyle) " )
55+ }
56+
57+ assertSnapshot (
58+ matching: vc,
59+ as: . image( on: config. device) ,
60+ file: file,
61+ testName: " \( testName) - \( config. name) \( suffix) " ,
62+ line: line
63+ )
64+ }
4965 }
5066 }
5167}
You can’t perform that action at this time.
0 commit comments