@@ -369,7 +369,7 @@ describe("ServiceUtils", () => {
369369 expect ( result . resultObjects ) . toBeUndefined ( ) ;
370370 } ) ;
371371
372- test ( "it returns rowCount equal to the resultObject list length" , ( ) => {
372+ test ( "when response.data.rowCount is undefined, it returns rowCount equal to the resultObject list length" , ( ) => {
373373 // Arrange
374374 const resultObject : StubResourceRecord [ ] = Factory . buildList (
375375 FactoryType . StubResourceRecord ,
@@ -380,6 +380,7 @@ describe("ServiceUtils", () => {
380380 {
381381 data : {
382382 resultObject : resultObject ,
383+ rowCount : undefined , // This is the important setup
383384 } ,
384385 }
385386 ) ;
@@ -394,6 +395,61 @@ describe("ServiceUtils", () => {
394395 expect ( result . rowCount ) . toBe ( resultObject . length ) ;
395396 } ) ;
396397
398+ test ( "when response.data.rowCount is null, it returns rowCount equal to the resultObject list length" , ( ) => {
399+ // Arrange
400+ const resultObject : StubResourceRecord [ ] = Factory . buildList (
401+ FactoryType . StubResourceRecord ,
402+ 2
403+ ) ;
404+ const axiosResponse = Factory . build < AxiosResponse > (
405+ AndcultureCodeFactoryType . AxiosResponse ,
406+ {
407+ data : {
408+ resultObject : resultObject ,
409+ rowCount : null , // This is the important setup
410+ } ,
411+ }
412+ ) ;
413+
414+ // Act
415+ const result = ServiceUtils . mapPagedAxiosResponse (
416+ StubResourceRecord ,
417+ axiosResponse
418+ ) ;
419+
420+ // Assert
421+ expect ( result . rowCount ) . toBe ( resultObject . length ) ;
422+ } ) ;
423+
424+ test ( "when response.data.rowCount has a value, it returns the mapped rowCount from the original response" , ( ) => {
425+ // Arrange
426+ const resultObject : StubResourceRecord [ ] = Factory . buildList (
427+ FactoryType . StubResourceRecord ,
428+ 2
429+ ) ;
430+ const rowCount = faker . random . number ( {
431+ min : resultObject . length + 1 ,
432+ } ) ; // This is the important setup (should be different from resultObject.length)
433+ const axiosResponse = Factory . build < AxiosResponse > (
434+ AndcultureCodeFactoryType . AxiosResponse ,
435+ {
436+ data : {
437+ resultObject : resultObject ,
438+ rowCount : rowCount ,
439+ } ,
440+ }
441+ ) ;
442+
443+ // Act
444+ const result = ServiceUtils . mapPagedAxiosResponse (
445+ StubResourceRecord ,
446+ axiosResponse
447+ ) ;
448+
449+ // Assert
450+ expect ( result . rowCount ) . toBe ( rowCount ) ;
451+ } ) ;
452+
397453 test ( "it returns the mapped status from the original response" , ( ) => {
398454 // Arrange
399455 const axiosResponse = Factory . build < AxiosResponse > (
0 commit comments