@@ -59,7 +59,7 @@ class OrderStoreTests: XCTestCase {
5959 wait ( for: [ expectation] , timeout: Constants . expectationTimeout)
6060 }
6161
62- /// Verifies that `OrderAction.retrieveOrders` effectively persists any retrieved sites .
62+ /// Verifies that `OrderAction.retrieveOrders` effectively persists any retrieved orders .
6363 ///
6464 func testRetrieveOrdersEffectivelyPersistsRetrievedOrders( ) {
6565 let expectation = self . expectation ( description: " Persist order list " )
@@ -78,6 +78,32 @@ class OrderStoreTests: XCTestCase {
7878 wait ( for: [ expectation] , timeout: Constants . expectationTimeout)
7979 }
8080
81+ /// Verifies that `OrderAction.retrieveOrders` effectively persists all of the order fields correctly.
82+ ///
83+ func testRetrieveOrdersEffectivelyPersistsOrderFields( ) {
84+ let expectation = self . expectation ( description: " Persist order list " )
85+ let orderStore = OrderStore ( dispatcher: dispatcher, storageManager: storageManager, network: network)
86+ let remoteOrder = sampleOrder ( )
87+
88+ network. simulateResponse ( requestUrlSuffix: " orders " , filename: " orders " )
89+ XCTAssertEqual ( viewStorage. countObjects ( ofType: Storage . Order. self) , 0 )
90+
91+ let action = OrderAction . retrieveOrders ( siteID: 123 ) { ( orders, error) in
92+ XCTAssertNil ( error)
93+ let predicate = NSPredicate ( format: " orderID = %ld " , remoteOrder. orderID)
94+ let storedOrder = self . viewStorage. firstObject ( ofType: Storage . Order. self, matching: predicate)
95+ let readOnlyStoredOrder = storedOrder? . toReadOnly ( )
96+ XCTAssertNotNil ( storedOrder)
97+ XCTAssertNotNil ( readOnlyStoredOrder)
98+ //XCTAssertEqual(readOnlyStoredOrder, remoteOrder)
99+
100+ expectation. fulfill ( )
101+ }
102+
103+ orderStore. onAction ( action)
104+ wait ( for: [ expectation] , timeout: Constants . expectationTimeout)
105+ }
106+
81107 /// Verifies that OrderAction.retrieveOrders returns an error whenever there is an error response from the backend.
82108 ///
83109 func testRetrieveOrdersReturnsErrorUponReponseError( ) {
0 commit comments