-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
DefaultsColorTests.swift
47 lines (40 loc) · 1.25 KB
/
DefaultsColorTests.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 Testing
import Defaults
private let suite_ = createSuite()
@Suite(.serialized)
final class DefaultsColorTests {
init() {
Defaults.removeAll(suite: suite_)
}
deinit {
Defaults.removeAll(suite: suite_)
}
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, visionOS 1.0, *)
@Test(.disabled()) // Fails on CI, but not locally.
func testPreservesColorSpace() {
let fixture = Color(.displayP3, red: 1, green: 0.3, blue: 0.7, opacity: 1)
let key = Defaults.Key<Color?>("independentColorPreservesColorSpaceKey", suite: suite_)
Defaults[key] = fixture
#expect(Defaults[key]?.cgColor != nil)
#expect(Defaults[key]?.cgColor?.colorSpace == fixture.cgColor?.colorSpace)
#expect(Defaults[key]?.cgColor == fixture.cgColor)
}
}
@Suite(.serialized)
final class DefaultsColorResolvedTests {
init() {
Defaults.removeAll(suite: suite_)
}
deinit {
Defaults.removeAll(suite: suite_)
}
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, visionOS 1, *)
@Test
func test() {
let fixture = Color(.displayP3, red: 1, green: 0.3, blue: 0.7, opacity: 1).resolve(in: .init())
let key = Defaults.Key<Color.Resolved?>("independentColorResolvedKey", suite: suite_)
Defaults[key] = fixture
#expect(Defaults[key]?.cgColor == fixture.cgColor)
}
}