@@ -47,6 +47,40 @@ class ShippingLabelStatusMapperTests: XCTestCase {
4747 XCTAssertEqual ( shippingLabel? . productNames, [ " WordPress Pennant " ] )
4848 }
4949
50+ func test_ShippingLabelStatusPollingResponse_is_properly_parsed_for_purchased_label_when_response_has_no_data_envelope( ) {
51+ // Given
52+ guard let shippingLabelList = mapLoadShippingLabelStatusWithoutDataEnvelope ( ) ,
53+ let shippingLabelResponse = shippingLabelList. first else {
54+ XCTFail ( )
55+ return
56+ }
57+
58+ // Assert
59+ XCTAssertEqual ( shippingLabelResponse. status, . purchased)
60+
61+ // Then
62+ let shippingLabel = shippingLabelResponse. getPurchasedLabel ( )
63+
64+ // Assert
65+ XCTAssertEqual ( shippingLabel? . siteID, sampleSiteID)
66+ XCTAssertEqual ( shippingLabel? . orderID, sampleOrderID)
67+ XCTAssertEqual ( shippingLabel? . shippingLabelID, 1825 )
68+ XCTAssertEqual ( shippingLabel? . carrierID, " usps " )
69+ XCTAssertEqual ( shippingLabel? . dateCreated, Date ( timeIntervalSince1970: 1623764362.682 ) )
70+ XCTAssertEqual ( shippingLabel? . packageName, " Small Flat Rate Box " )
71+ XCTAssertEqual ( shippingLabel? . rate, 7.9 )
72+ XCTAssertEqual ( shippingLabel? . currency, " USD " )
73+ XCTAssertEqual ( shippingLabel? . trackingNumber, " 9405500205309072644962 " )
74+ XCTAssertEqual ( shippingLabel? . serviceName, " USPS - Priority Mail " )
75+ XCTAssertEqual ( shippingLabel? . refundableAmount, 7.9 )
76+ XCTAssertEqual ( shippingLabel? . status, ShippingLabelStatus . purchased)
77+ XCTAssertNil ( shippingLabel? . refund)
78+ XCTAssertEqual ( shippingLabel? . originAddress, ShippingLabelAddress . fake ( ) )
79+ XCTAssertEqual ( shippingLabel? . destinationAddress, ShippingLabelAddress . fake ( ) )
80+ XCTAssertEqual ( shippingLabel? . productIDs, [ 89 ] )
81+ XCTAssertEqual ( shippingLabel? . productNames, [ " WordPress Pennant " ] )
82+ }
83+
5084 /// Verifies that the Shipping Label Status Polling Response is parsed correctly when it receives a pending shipping label purchase.
5185 ///
5286 func test_ShippingLabelStatusPollingResponse_is_properly_parsed_for_pending_label_purchase( ) {
@@ -81,6 +115,12 @@ private extension ShippingLabelStatusMapperTests {
81115 return mapShippingLabelStatus ( from: " shipping-label-status-success " )
82116 }
83117
118+ /// Returns the ShippingLabelStatusMapper output upon receiving `shipping-label-status-success-without-data`
119+ ///
120+ func mapLoadShippingLabelStatusWithoutDataEnvelope( ) -> [ ShippingLabelStatusPollingResponse ] ? {
121+ return mapShippingLabelStatus ( from: " shipping-label-status-success-without-data " )
122+ }
123+
84124 /// Returns the ShippingLabelStatusMapper output upon receiving `shipping-label-purchase-success`
85125 ///
86126 func mapLoadShippingLabelPurchaseStatus( ) -> [ ShippingLabelStatusPollingResponse ] ? {
0 commit comments