@@ -207,7 +207,7 @@ describe("the fetch function", function () {
207207 respond ( 300 , "error" ) ;
208208 this . httpBackend . expectGET ( testCategoryHref ) ;
209209
210- SpringDataRestAdapter . process ( this . rawResponse , fetchLinkName ) . then ( function ( responseData ) {
210+ SpringDataRestAdapter . process ( this . rawResponse , fetchLinkName ) . then ( function ( ) {
211211 throw new Error ( "Should not be called when the promise is rejected" )
212212 } , function ( error ) {
213213 expect ( error . status ) . toBe ( 300 ) ;
@@ -243,5 +243,38 @@ describe("the fetch function", function () {
243243 this . httpBackend . verifyNoOutstandingExpectation ( ) ;
244244 } ) ;
245245
246+
247+ it ( "must process the fetched responses as all the other responses" , function ( ) {
248+
249+ var embeddedNewKey = this . config . embeddedNewKey ;
250+ var fetchLinkName = 'parentCategory' ;
251+
252+ // the correct link href url
253+ var firstParentCategoryHref = 'http://localhost:8080/categories/f974f5ef-a951-43b4-9027-4d2163216e54/parentCategory' ;
254+ var secondParentCategoryHref = 'http://localhost:8080/categories/b5ba38d5-98d3-4579-8709-a28549406697/parentCategory' ;
255+
256+ // check if the underlying fetch function is called with the correct href url
257+ var firstExpectedResult = mockData ( ) ;
258+ var secondExpectedResult = mockData ( ) ;
259+
260+ this . httpBackend . whenGET ( firstParentCategoryHref ) .
261+ respond ( 200 , firstExpectedResult ) ;
262+ this . httpBackend . expectGET ( firstParentCategoryHref ) ;
263+
264+ this . httpBackend . whenGET ( secondParentCategoryHref ) .
265+ respond ( 200 , secondExpectedResult ) ;
266+ this . httpBackend . expectGET ( secondParentCategoryHref ) ;
267+
268+ SpringDataRestAdapter . process ( this . rawResponse , fetchLinkName ) . then ( function ( processedData ) {
269+ // expect the fetched objects
270+ expect ( processedData [ embeddedNewKey ] [ 0 ] [ fetchLinkName ] [ embeddedNewKey ] [ 0 ] [ 'name' ] ) . toEqual ( 'Test category 1' ) ;
271+ expect ( processedData [ embeddedNewKey ] [ 1 ] [ fetchLinkName ] [ embeddedNewKey ] [ 1 ] [ 'name' ] ) . toEqual ( 'Test category 2' ) ;
272+ } ) ;
273+
274+ this . httpBackend . flush ( ) ;
275+ this . httpBackend . verifyNoOutstandingRequest ( ) ;
276+ this . httpBackend . verifyNoOutstandingExpectation ( ) ;
277+ } ) ;
278+
246279} ) ;
247280
0 commit comments