Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Networking/Networking.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
B505F6D720BEE58800BB1B69 /* AccountRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6D620BEE58800BB1B69 /* AccountRemoteTests.swift */; };
B505F6EA20BEFC3700BB1B69 /* MockupNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518662620A09BCC00037A38 /* MockupNetwork.swift */; };
B505F6EC20BEFDC200BB1B69 /* Loader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518663420A0A2E800037A38 /* Loader.swift */; };
B5147876211B9227007562E5 /* broken-orders-mark-2.json in Resources */ = {isa = PBXBuildFile; fileRef = B5147875211B9227007562E5 /* broken-orders-mark-2.json */; };
B518662220A097C200037A38 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518662120A097C200037A38 /* Network.swift */; };
B518662420A099BF00037A38 /* AlamofireNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518662320A099BF00037A38 /* AlamofireNetwork.swift */; };
B518662A20A09C6F00037A38 /* OrdersRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B518662920A09C6F00037A38 /* OrdersRemoteTests.swift */; };
Expand Down Expand Up @@ -146,6 +147,7 @@
B505F6D220BEE3A500BB1B69 /* AccountMapperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountMapperTests.swift; sourceTree = "<group>"; };
B505F6D420BEE4E600BB1B69 /* me.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = me.json; sourceTree = "<group>"; };
B505F6D620BEE58800BB1B69 /* AccountRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountRemoteTests.swift; sourceTree = "<group>"; };
B5147875211B9227007562E5 /* broken-orders-mark-2.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "broken-orders-mark-2.json"; sourceTree = "<group>"; };
B518662120A097C200037A38 /* Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = "<group>"; };
B518662320A099BF00037A38 /* AlamofireNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlamofireNetwork.swift; sourceTree = "<group>"; };
B518662620A09BCC00037A38 /* MockupNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockupNetwork.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -398,6 +400,7 @@
74C8F06F20EEC3A800B6EDC9 /* broken-notes.json */,
74C8F06B20EEBD5D00B6EDC9 /* broken-order.json */,
CE20179220E3EFA7005B4C18 /* broken-orders.json */,
B5147875211B9227007562E5 /* broken-orders-mark-2.json */,
B58D10C72114D21C00107ED4 /* generic_error.json */,
B505F6D420BEE4E600BB1B69 /* me.json */,
B58D10C92114D22E00107ED4 /* new-order-note.json */,
Expand Down Expand Up @@ -582,6 +585,7 @@
B58D10CA2114D22E00107ED4 /* new-order-note.json in Resources */,
74C8F06C20EEBD5D00B6EDC9 /* broken-order.json in Resources */,
B58D10C82114D21D00107ED4 /* generic_error.json in Resources */,
B5147876211B9227007562E5 /* broken-orders-mark-2.json in Resources */,
743BF8BE21191B63008A9D87 /* site-visits.json in Resources */,
B505F6D520BEE4E700BB1B69 /* me.json in Resources */,
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */,
Expand Down
2 changes: 1 addition & 1 deletion Networking/Networking/Model/OrderItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct OrderItem: Decodable {
public let name: String
public let productID: Int
public let quantity: Int
public let sku: String
public let sku: String?
public let subtotal: String
public let subtotalTax: String
public let taxClass: String
Expand Down
26 changes: 25 additions & 1 deletion Networking/NetworkingTests/Mapper/OrderListMapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ class OrderListMapperTests: XCTestCase {
let orderModifiedString = format.string(from: brokenOrder.dateModified)
XCTAssertEqual(orderModifiedString, todayCreatedString)
}

/// Verifies that `broken-orders-mark-2` gets properly parsed: 6 Orders with 2 items each, and the SKU property should
/// always be set to null.
///
/// Ref. Issue: https://github.com/woocommerce/woocommerce-ios/issues/221
///
func testOrderListWithBreakingFormatIsProperlyParsed() {
let orders = mapLoadBrokenOrdersResponseMarkII()
XCTAssertEqual(orders.count, 6)

for order in orders {
XCTAssertEqual(order.items.count, 2)

for item in order.items {
XCTAssertNil(item.sku)
}
}
}
}


Expand All @@ -130,9 +148,15 @@ private extension OrderListMapperTests {
return mapOrders(from: "orders-load-all")
}

/// Returns the OrderlistMapper output upon receiving `broken-order`
/// Returns the OrderListMapper output upon receiving `broken-order`
///
func mapLoadBrokenOrderResponse() -> [Order] {
return mapOrders(from: "broken-orders")
}

/// Returns the OrderListMapper output upon receiving `broken-orders-mark-2`
///
func mapLoadBrokenOrdersResponseMarkII() -> [Order] {
return mapOrders(from: "broken-orders-mark-2")
}
}
Loading