-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exclusive access problem in preview traits. (#306)
* Fix exclusive access problem in preview traits. * fix
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#if canImport(Testing) && (os(iOS) || os(macOS) || os(tvOS) || os(watchOS)) | ||
import Dependencies | ||
import Testing | ||
import SwiftUI | ||
|
||
@Suite | ||
@MainActor | ||
struct PreviewTraitsTests { | ||
@Test | ||
@available(iOS 18, macOS 15, tvOS 18, watchOS 11, visionOS 2, *) | ||
func dependency() { | ||
_ = PreviewTrait.dependency(\.date.now, Date(timeIntervalSince1970: 1_234_567_890)) | ||
withDependencies { | ||
$0.context = .preview | ||
} operation: { | ||
@Dependency(\.date.now) var now | ||
#expect(now == Date(timeIntervalSince1970: 1_234_567_890)) | ||
} | ||
} | ||
} | ||
#endif |