Skip to content

Commit 24d6d6c

Browse files
committed
Add test for custom form data in purchased package
1 parent e2ba250 commit 24d6d6c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Modules/Tests/NetworkingTests/Remote/WooShippingRemoteTests.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,15 @@ final class WooShippingRemoteTests: XCTestCase {
366366

367367
let shipmentID = "1"
368368
let hazmatCategory = "test-hazmat"
369-
let customsForm = ShippingLabelCustomsForm.fake().copy(items: [.fake(), .fake()])
369+
let customsForm = ShippingLabelCustomsForm(packageID: "test",
370+
packageName: "ups-test",
371+
contentsType: .merchandise,
372+
contentExplanation: "",
373+
restrictionType: .none,
374+
restrictionComments: "",
375+
nonDeliveryOption: .return,
376+
itn: "",
377+
items: [.fake(), .fake()])
370378

371379
let package = WooShippingPackagePurchase.fake().copy(
372380
shipmentID: shipmentID,
@@ -424,6 +432,14 @@ final class WooShippingRemoteTests: XCTestCase {
424432
XCTAssertEqual(firstPackage["additional_handling"] as? Bool, true)
425433
XCTAssertEqual(firstPackage["hazmat"] as? String, hazmatCategory)
426434

435+
/// customs form details need to be present in package
436+
XCTAssertEqual(try XCTUnwrap(firstPackage["items"] as? [Any]).count, 2)
437+
XCTAssertEqual(firstPackage["contents_type"] as? String, "merchandise")
438+
XCTAssertEqual(firstPackage["restriction_type"] as? String, "none")
439+
XCTAssertEqual(firstPackage["non_delivery_option"] as? String, "return")
440+
XCTAssertEqual(firstPackage["restriction_comments"] as? String, "")
441+
XCTAssertEqual(firstPackage["contents_explanation"] as? String, "")
442+
427443
let selectedRateParam = try XCTUnwrap(request.parameters["selected_rate"] as? [String: Any])
428444
let parentValue = try XCTUnwrap(selectedRateParam["parent"] as? [String: Any])
429445
XCTAssertEqual(parentValue["rate"] as? Double, package.selectedRate.rate.rate)

0 commit comments

Comments
 (0)