@@ -147,4 +147,54 @@ final class InboxNotesRemoteTests: XCTestCase {
147147 let resultError = try XCTUnwrap ( result. failure as? NetworkError )
148148 XCTAssertEqual ( resultError, . unacceptableStatusCode( statusCode: 500 ) )
149149 }
150+
151+ // MARK: - Mark an Inbox Note as `actioned`
152+
153+ /// Verifies that markInboxNoteAsActioned properly parses the `InboxNote` sample response.
154+ ///
155+ func test_markInboxNoteAsActioned_properly_returns_parsed_InboxNote( ) throws {
156+ // Given
157+ let remote = InboxNotesRemote ( network: network)
158+ let sampleInboxNoteID : Int64 = 296
159+ let sampleActionID : Int64 = 13329
160+
161+ network. simulateResponse ( requestUrlSuffix: " admin/notes/ \( sampleInboxNoteID) /action/ \( sampleActionID) " , filename: " inbox-note " )
162+
163+ // When
164+ let result = waitFor { promise in
165+ remote. markInboxNoteAsActioned ( for: self . sampleSiteID, noteID: sampleInboxNoteID, actionID: sampleActionID) { result in
166+ promise ( result)
167+ }
168+ }
169+
170+ // Then
171+ XCTAssert ( result. isSuccess)
172+ let inboxNote = try XCTUnwrap ( result. get ( ) )
173+ XCTAssertEqual ( inboxNote. id, sampleInboxNoteID)
174+ XCTAssertEqual ( inboxNote. actions. first? . id, sampleActionID)
175+ }
176+
177+ /// Verifies that markInboxNoteAsActioned properly relays Networking Layer errors.
178+ ///
179+ func test_markInboxNoteAsActioned_properly_relays_networking_errors( ) throws {
180+ // Given
181+ let remote = InboxNotesRemote ( network: network)
182+ let sampleInboxNoteID : Int64 = 296
183+ let sampleActionID : Int64 = 13329
184+
185+ let error = NetworkError . unacceptableStatusCode ( statusCode: 500 )
186+ network. simulateError ( requestUrlSuffix: " admin/notes/ \( sampleInboxNoteID) /action/ \( sampleActionID) " , error: error)
187+
188+ // When
189+ let result = waitFor { promise in
190+ remote. markInboxNoteAsActioned ( for: self . sampleSiteID, noteID: sampleInboxNoteID, actionID: sampleActionID) { result in
191+ promise ( result)
192+ }
193+ }
194+
195+ // Then
196+ XCTAssertTrue ( result. isFailure)
197+ let resultError = try XCTUnwrap ( result. failure as? NetworkError )
198+ XCTAssertEqual ( resultError, . unacceptableStatusCode( statusCode: 500 ) )
199+ }
150200}
0 commit comments