@@ -211,6 +211,27 @@ final class OrdersRemoteTests: XCTestCase {
211211 wait ( for: [ expectation] , timeout: Constants . expectationTimeout)
212212 }
213213
214+ func test_update_order_properly_encodes_shipping_lines_for_removal_from_order( ) throws {
215+ // Given
216+ let remote = OrdersRemote ( network: network)
217+ let shipping = ShippingLine ( shippingID: 333 , methodTitle: " Shipping " , methodID: nil , total: " 1.23 " , totalTax: " " , taxes: [ ] )
218+ let order = Order . fake ( ) . copy ( shippingLines: [ shipping] )
219+
220+ // When
221+ remote. updateOrder ( from: 123 , order: order, fields: [ . shippingLines] ) { result in }
222+
223+ // Then
224+ let request = try XCTUnwrap ( network. requestsForResponseData. last as? JetpackRequest )
225+ let received = try XCTUnwrap ( request. parameters [ " shipping_lines " ] as? [ [ String : AnyHashable ] ] ) . first
226+ let expected : [ String : AnyHashable ] = [
227+ " id " : shipping. shippingID,
228+ " method_title " : shipping. methodTitle,
229+ " method_id " : NSNull ( ) ,
230+ " total " : shipping. total
231+ ]
232+ assertEqual ( received, expected)
233+ }
234+
214235
215236 // MARK: - Load Order Notes Tests
216237
@@ -394,7 +415,7 @@ final class OrdersRemoteTests: XCTestCase {
394415 let expected : [ String : AnyHashable ] = [
395416 " id " : shipping. shippingID,
396417 " method_title " : shipping. methodTitle,
397- " method_id " : shipping. methodID,
418+ " method_id " : shipping. methodID ?? " " ,
398419 " total " : shipping. total
399420 ]
400421 assertEqual ( received, expected)
0 commit comments