1+ import Dependencies
12import DependenciesTestSupport
3+ import Foundation
24import InlineSnapshotTesting
35import SnapshotTestingCustomDump
46import Testing
@@ -8,6 +10,9 @@ import Testing
810extension BaseTestSuite {
911 @MainActor
1012 struct RemindersListsTests {
13+ @Dependency ( \. defaultDatabase) var database
14+ @Dependency ( \. defaultSyncEngine) var syncEngine
15+
1116 @Test func basics( ) async throws {
1217 let model = RemindersListsModel ( )
1318 try await model. $remindersLists. load ( )
@@ -100,5 +105,54 @@ extension BaseTestSuite {
100105 """
101106 }
102107 }
108+
109+ @Test func share( ) async throws {
110+ let model = RemindersListsModel ( )
111+
112+ let personalRemindersList = try #require(
113+ try await database. read { db in
114+ try RemindersList . find ( UUID ( 0 ) ) . fetchOne ( db)
115+ }
116+ )
117+ let _ = try await syncEngine. share ( record: personalRemindersList, configure: { _ in } )
118+
119+ try await model. $remindersLists. load ( )
120+ assertInlineSnapshot ( of: model. remindersLists, as: . customDump) {
121+ """
122+ [
123+ [0]: RemindersListsModel.ReminderListState(
124+ remindersCount: 4,
125+ remindersList: RemindersList(
126+ id: UUID(00000000-0000-0000-0000-000000000000),
127+ color: 1218047999,
128+ position: 1,
129+ title: " Personal "
130+ ),
131+ share: CKShare()
132+ ),
133+ [1]: RemindersListsModel.ReminderListState(
134+ remindersCount: 2,
135+ remindersList: RemindersList(
136+ id: UUID(00000000-0000-0000-0000-000000000001),
137+ color: 3985191935,
138+ position: 2,
139+ title: " Family "
140+ ),
141+ share: nil
142+ ),
143+ [2]: RemindersListsModel.ReminderListState(
144+ remindersCount: 2,
145+ remindersList: RemindersList(
146+ id: UUID(00000000-0000-0000-0000-000000000002),
147+ color: 2992493567,
148+ position: 3,
149+ title: " Business "
150+ ),
151+ share: nil
152+ )
153+ ]
154+ """
155+ }
156+ }
103157 }
104158}
0 commit comments