Skip to content

Commit 066d43c

Browse files
committed
Adds OrderRemote tests for notes and soem missing tests
1 parent 9f6d880 commit 066d43c

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

Networking/NetworkingTests/Remote/OrdersRemoteTests.swift

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class OrdersRemoteTests: XCTestCase {
2626
}
2727

2828

29+
// MARK: - Load All Orders Tests
30+
2931
/// Verifies that loadAllOrders properly parses the `orders-load-all` sample response.
3032
///
3133
func testLoadAllOrdersProperlyReturnsParsedOrders() {
@@ -44,6 +46,24 @@ class OrdersRemoteTests: XCTestCase {
4446
wait(for: [expectation], timeout: Constants.expectationTimeout)
4547
}
4648

49+
/// Verifies that loadAllOrders properly relays Networking Layer errors.
50+
///
51+
func testLoadAllOrdersProperlyRelaysNetwokingErrors() {
52+
let remote = OrdersRemote(network: network)
53+
let expectation = self.expectation(description: "Load All Orders")
54+
55+
remote.loadAllOrders(for: sampleSiteID) { orders, error in
56+
XCTAssertNil(orders)
57+
XCTAssertNotNil(error)
58+
expectation.fulfill()
59+
}
60+
61+
wait(for: [expectation], timeout: Constants.expectationTimeout)
62+
}
63+
64+
65+
// MARK: - Load Order Tests
66+
4767
/// Verifies that loadOrder properly parses the `order` sample response.
4868
///
4969
func testLoadSingleOrderProperlyReturnsParsedOrder() {
@@ -61,21 +81,24 @@ class OrdersRemoteTests: XCTestCase {
6181
wait(for: [expectation], timeout: Constants.expectationTimeout)
6282
}
6383

64-
/// Verifies that loadAllOrders properly relays Networking Layer errors.
84+
/// Verifies that loadOrder properly relays any Networking Layer errors.
6585
///
66-
func testLoadAllOrdersProperlyRelaysNetwokingErrors() {
86+
func testLoadSingleOrderProperlyRelaysNetwokingErrors() {
6787
let remote = OrdersRemote(network: network)
68-
let expectation = self.expectation(description: "Load All Orders")
88+
let expectation = self.expectation(description: "Update Order")
6989

70-
remote.loadAllOrders(for: sampleSiteID) { orders, error in
71-
XCTAssertNil(orders)
90+
remote.loadOrder(for: sampleSiteID, orderID: sampleOrderID) { order, error in
91+
XCTAssertNil(order)
7292
XCTAssertNotNil(error)
7393
expectation.fulfill()
7494
}
7595

7696
wait(for: [expectation], timeout: Constants.expectationTimeout)
7797
}
7898

99+
100+
// MARK: - Update Orders Tests
101+
79102
/// Verifies that updateOrder properly parses the `order` sample response.
80103
///
81104
func testUpdateOrderProperlyReturnsParsedOrder() {
@@ -107,4 +130,40 @@ class OrdersRemoteTests: XCTestCase {
107130

108131
wait(for: [expectation], timeout: Constants.expectationTimeout)
109132
}
133+
134+
135+
// MARK: - Load Order Notes Tests
136+
137+
/// Verifies that loadOrderNotes properly parses the `order-notes` sample response.
138+
///
139+
func testLoadOrderNotesProperlyReturnsParsedNotes() {
140+
let remote = OrdersRemote(network: network)
141+
let expectation = self.expectation(description: "Load Order Notes")
142+
143+
network.simulateResponse(requestUrlSuffix: "orders/\(sampleOrderID)/notes/", filename: "order-notes")
144+
145+
remote.loadOrderNotes(for: sampleSiteID, orderID: sampleOrderID) { orderNotes, error in
146+
XCTAssertNil(error)
147+
XCTAssertNotNil(orderNotes)
148+
XCTAssertEqual(orderNotes?.count, 18)
149+
expectation.fulfill()
150+
}
151+
152+
wait(for: [expectation], timeout: Constants.expectationTimeout)
153+
}
154+
155+
/// Verifies that loadOrderNotes properly relays any Networking Layer errors.
156+
///
157+
func testLoadOrderNotesProperlyRelaysNetwokingErrors() {
158+
let remote = OrdersRemote(network: network)
159+
let expectation = self.expectation(description: "Load Order Notes")
160+
161+
remote.loadOrderNotes(for: sampleSiteID, orderID: sampleOrderID) { orderNotes, error in
162+
XCTAssertNil(orderNotes)
163+
XCTAssertNotNil(error)
164+
expectation.fulfill()
165+
}
166+
167+
wait(for: [expectation], timeout: Constants.expectationTimeout)
168+
}
110169
}

0 commit comments

Comments
 (0)