-
Notifications
You must be signed in to change notification settings - Fork 0
[#400] 위젯 예외 케이스 테스트를 보강한다 #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
68 changes: 68 additions & 0 deletions
68
DevLog_Unit/Widget/WidgetHeatmapPlaceholderShapeTests.swift
This file contains hidden or 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,68 @@ | ||
| // | ||
| // WidgetHeatmapPlaceholderShapeTests.swift | ||
| // DevLog_Unit | ||
| // | ||
| // Created by opfic on 4/30/26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import Testing | ||
| @testable import DevLog | ||
|
|
||
| struct WidgetHeatmapPlaceholderShapeTests { | ||
| @Test("Heatmap 위젯 placeholder는 현재 월과 분기의 실제 날짜 위치를 사용한다") | ||
| func heatmap_위젯_placeholder는_현재_월과_분기의_실제_날짜_위치를_사용한다() throws { | ||
| let calendar = Calendar(identifier: .gregorian) | ||
| let date = try #require(calendar.date(from: DateComponents(year: 2026, month: 5, day: 15))) | ||
|
|
||
| let widgetHeatmapPlaceholderShape = WidgetHeatmapPlaceholderShape( | ||
| date: date, | ||
| calendar: calendar | ||
| ) | ||
|
|
||
| #expect(widgetHeatmapPlaceholderShape.currentMonthWeekCounts == [6]) | ||
| #expect(widgetHeatmapPlaceholderShape.quarterWeekCounts == [5, 6, 5]) | ||
|
|
||
| let currentMonth = try #require(widgetHeatmapPlaceholderShape.currentMonths.first) | ||
| #expect(currentMonth.weeks.count == 6) | ||
| #expect(currentMonth.weeks[0].days.map(\.isVisible) == [ | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| true, | ||
| true | ||
| ]) | ||
| #expect(currentMonth.weeks[5].days.map(\.isVisible) == [ | ||
| true, | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| false | ||
| ]) | ||
|
|
||
| let quarterMonths = widgetHeatmapPlaceholderShape.quarterMonths | ||
| #expect(quarterMonths.map(\.weeks.count) == [5, 6, 5]) | ||
| #expect(quarterMonths[0].weeks[0].days.map(\.isVisible) == [ | ||
| false, | ||
| false, | ||
| false, | ||
| true, | ||
| true, | ||
| true, | ||
| true | ||
| ]) | ||
| #expect(quarterMonths[2].weeks[4].days.map(\.isVisible) == [ | ||
| true, | ||
| true, | ||
| true, | ||
| false, | ||
| false, | ||
| false, | ||
| false | ||
| ]) | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
DevLog_Unit/Widget/WidgetSnapshotPreferenceStoreTests.swift
This file contains hidden or 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,57 @@ | ||
| // | ||
| // WidgetSnapshotPreferenceStoreTests.swift | ||
| // DevLog_Unit | ||
| // | ||
| // Created by opfic on 4/30/26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import Testing | ||
| @testable import DevLog | ||
|
|
||
| struct WidgetSnapshotPreferenceStoreTests { | ||
| @Test("Heatmap activity kind 설정이 비어 있으면 전체 kind를 사용한다") | ||
| func heatmap_activity_kind_설정이_비어_있으면_전체_kind를_사용한다() { | ||
| let widgetSnapshotPreferenceStore = makeStore() | ||
|
|
||
| #expect(widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .completed, .deleted])) | ||
| } | ||
|
|
||
| @Test("Heatmap activity kind 설정에 유효하지 않은 값만 있으면 전체 kind를 사용한다") | ||
| func heatmap_activity_kind_설정에_유효하지_않은_값만_있으면_전체_kind를_사용한다() { | ||
| let widgetSnapshotPreferenceStore = makeStore() | ||
|
|
||
| widgetSnapshotPreferenceStore.setHeatmapActivityTypes(["unknown"]) | ||
|
|
||
| #expect(widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .completed, .deleted])) | ||
| } | ||
|
|
||
| @Test("Heatmap activity kind 설정은 유효한 값만 유지한다") | ||
| func heatmap_activity_kind_설정은_유효한_값만_유지한다() { | ||
| let widgetSnapshotPreferenceStore = makeStore() | ||
|
|
||
| widgetSnapshotPreferenceStore.setHeatmapActivityTypes(["created", "unknown", "deleted", "created"]) | ||
|
|
||
| #expect(widgetSnapshotPreferenceStore.selectedActivityKinds() == Set([.created, .deleted])) | ||
| } | ||
|
|
||
| @Test("Today display option 설정이 깨져 있으면 기본 옵션을 사용한다") | ||
| func today_display_option_설정이_깨져_있으면_기본_옵션을_사용한다() { | ||
| let suiteName = "WidgetSnapshotPreferenceStoreTests.\(UUID().uuidString)" | ||
| let userDefaults = UserDefaults(suiteName: suiteName) ?? .standard | ||
| userDefaults.removePersistentDomain(forName: suiteName) | ||
| let widgetSnapshotPreferenceStore = WidgetSnapshotPreferenceStore(userDefaults: userDefaults) | ||
|
|
||
| userDefaults.set("invalid", forKey: "Today.dueDateVisibility") | ||
| userDefaults.set("invalid", forKey: "Today.focusVisibility") | ||
|
|
||
| #expect(widgetSnapshotPreferenceStore.todayDisplayOptions() == .default) | ||
| } | ||
|
|
||
| private func makeStore() -> WidgetSnapshotPreferenceStore { | ||
| let suiteName = "WidgetSnapshotPreferenceStoreTests.\(UUID().uuidString)" | ||
| let userDefaults = UserDefaults(suiteName: suiteName) ?? .standard | ||
| userDefaults.removePersistentDomain(forName: suiteName) | ||
| return WidgetSnapshotPreferenceStore(userDefaults: userDefaults) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.