@@ -49,6 +49,16 @@ class DeletehRequestTests: XCTestCase {
4949 waitForExpectations ( timeout: 0.1 )
5050 }
5151
52+ func testDELETEVoidAsyncWorks( ) async throws {
53+ MockingURLProtocol . mockedResponse =
54+ """
55+ { " response " : " OK " }
56+ """
57+ let _: Void = try await network. delete ( " /users " )
58+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . httpMethod, " DELETE " )
59+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . url? . absoluteString, " https://mocked.com/users " )
60+ }
61+
5262 func testDELETEDataWorks( ) {
5363 MockingURLProtocol . mockedResponse =
5464 """
@@ -73,6 +83,17 @@ class DeletehRequestTests: XCTestCase {
7383 waitForExpectations ( timeout: 0.1 )
7484 }
7585
86+ func testDELETEDataAsyncWorks( ) async throws {
87+ MockingURLProtocol . mockedResponse =
88+ """
89+ { " response " : " OK " }
90+ """
91+ let data : Data = try await network. delete ( " /users " )
92+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . httpMethod, " DELETE " )
93+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . url? . absoluteString, " https://mocked.com/users " )
94+ XCTAssertEqual ( data, MockingURLProtocol . mockedResponse. data ( using: String . Encoding. utf8) )
95+ }
96+
7697 func testDELETEJSONWorks( ) {
7798 MockingURLProtocol . mockedResponse =
7899 """
@@ -103,6 +124,22 @@ class DeletehRequestTests: XCTestCase {
103124 waitForExpectations ( timeout: 0.1 )
104125 }
105126
127+ func testDELETEJSONAsyncWorks( ) async throws {
128+ MockingURLProtocol . mockedResponse =
129+ """
130+ { " response " : " OK " }
131+ """
132+ let json : Any = try await network. delete ( " /users " )
133+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . httpMethod, " DELETE " )
134+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . url? . absoluteString, " https://mocked.com/users " )
135+ let data = try ? JSONSerialization . data ( withJSONObject: json, options: [ ] )
136+ let expectedResponseData =
137+ """
138+ { " response " : " OK " }
139+ """ . data ( using: String . Encoding. utf8)
140+ XCTAssertEqual ( data, expectedResponseData)
141+ }
142+
106143 func testDELETENetworkingJSONDecodableWorks( ) {
107144 MockingURLProtocol . mockedResponse =
108145 """
@@ -131,6 +168,7 @@ class DeletehRequestTests: XCTestCase {
131168 . store ( in: & cancellables)
132169 waitForExpectations ( timeout: 0.1 )
133170 }
171+
134172 func testDELETEDecodableWorks( ) {
135173 MockingURLProtocol . mockedResponse =
136174 """
@@ -159,6 +197,21 @@ class DeletehRequestTests: XCTestCase {
159197 . store ( in: & cancellables)
160198 waitForExpectations ( timeout: 0.1 )
161199 }
200+
201+ func testDELETEDecodableAsyncWorks( ) async throws {
202+ MockingURLProtocol . mockedResponse =
203+ """
204+ {
205+ " firstname " : " John " ,
206+ " lastname " : " Doe " ,
207+ }
208+ """
209+ let userJSON : UserJSON = try await network. delete ( " /users/1 " )
210+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . httpMethod, " DELETE " )
211+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . url? . absoluteString, " https://mocked.com/users/1 " )
212+ XCTAssertEqual ( userJSON. firstname, " John " )
213+ XCTAssertEqual ( userJSON. lastname, " Doe " )
214+ }
162215
163216 func testDELETEArrayOfDecodableWorks( ) {
164217 MockingURLProtocol . mockedResponse =
@@ -196,6 +249,29 @@ class DeletehRequestTests: XCTestCase {
196249 . store ( in: & cancellables)
197250 waitForExpectations ( timeout: 0.1 )
198251 }
252+
253+ func testDELETEArrayOfDecodableAsyncWorks( ) async throws {
254+ MockingURLProtocol . mockedResponse =
255+ """
256+ [
257+ {
258+ " firstname " : " John " ,
259+ " lastname " : " Doe "
260+ },
261+ {
262+ " firstname " : " Jimmy " ,
263+ " lastname " : " Punchline "
264+ }
265+ ]
266+ """
267+ let users : [ UserJSON ] = try await network. delete ( " /users " )
268+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . httpMethod, " DELETE " )
269+ XCTAssertEqual ( MockingURLProtocol . currentRequest? . url? . absoluteString, " https://mocked.com/users " )
270+ XCTAssertEqual ( users [ 0 ] . firstname, " John " )
271+ XCTAssertEqual ( users [ 0 ] . lastname, " Doe " )
272+ XCTAssertEqual ( users [ 1 ] . firstname, " Jimmy " )
273+ XCTAssertEqual ( users [ 1 ] . lastname, " Punchline " )
274+ }
199275
200276 func testDELETEArrayOfDecodableWithKeypathWorks( ) {
201277 MockingURLProtocol . mockedResponse =
0 commit comments