-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidgetSnapshotPreferenceStoreTests.swift
More file actions
59 lines (46 loc) · 2.43 KB
/
Copy pathWidgetSnapshotPreferenceStoreTests.swift
File metadata and controls
59 lines (46 loc) · 2.43 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
//
// WidgetSnapshotPreferenceStoreTests.swift
// DevLogWidgetTests
//
// Created by opfic on 4/30/26.
//
import Foundation
import DevLogCore
import Testing
@testable import DevLogWidget
struct WidgetSnapshotPreferenceStoreTests {
@Test("Heatmap activity kind 설정이 비어 있으면 전체 kind를 사용한다")
func heatmap_activity_kind_설정이_비어_있으면_전체_kind를_사용한다() {
let fixture = makeFixture()
#expect(fixture.widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .completed, .deleted]))
}
@Test("Heatmap activity kind 설정에 유효하지 않은 값만 있으면 전체 kind를 사용한다")
func heatmap_activity_kind_설정에_유효하지_않은_값만_있으면_전체_kind를_사용한다() {
let fixture = makeFixture()
fixture.widgetSnapshotPreferenceStore.setHeatmapActivityTypes(["unknown"])
#expect(fixture.widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .completed, .deleted]))
}
@Test("Heatmap activity kind 설정은 유효한 값만 유지한다")
func heatmap_activity_kind_설정은_유효한_값만_유지한다() {
let fixture = makeFixture()
fixture.widgetSnapshotPreferenceStore.setHeatmapActivityTypes(["created", "unknown", "deleted", "created"])
#expect(fixture.widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .deleted]))
}
@Test("Today display option 설정이 깨져 있으면 기본 옵션을 사용한다")
func today_display_option_설정이_깨져_있으면_기본_옵션을_사용한다() {
let fixture = makeFixture()
fixture.userDefaults.set("invalid", forKey: "Today.dueDateVisibility")
fixture.userDefaults.set("invalid", forKey: "Today.focusVisibility")
#expect(fixture.widgetSnapshotPreferenceStore.todayDisplayOptions() == .default)
}
private func makeFixture() -> (
widgetSnapshotPreferenceStore: WidgetSnapshotPreferenceStoreImpl,
userDefaults: UserDefaults
) {
let suiteName = "WidgetSnapshotPreferenceStoreTests.\(UUID().uuidString)"
let userDefaults = UserDefaults(suiteName: suiteName) ?? .standard
userDefaults.removePersistentDomain(forName: suiteName)
let widgetSnapshotPreferenceStore = WidgetSnapshotPreferenceStoreImpl(userDefaults: userDefaults)
return (widgetSnapshotPreferenceStore, userDefaults)
}
}