@@ -14,6 +14,7 @@ import { EventsGateway } from '../shared/events/events.gateway';
1414import { CommentDto } from '../shared/dto/comment.dto' ;
1515import { TestVariationsService } from '../test-variations/test-variations.service' ;
1616import { convertBaselineDataToQuery } from '../shared/dto/baseline-data.dto' ;
17+ import { TestRunDto } from './dto/testRun.dto' ;
1718
1819jest . mock ( 'pixelmatch' ) ;
1920jest . mock ( './dto/testRunResult.dto' ) ;
@@ -24,6 +25,7 @@ const initService = async ({
2425 testRunFindUniqueMock = jest . fn ( ) ,
2526 testRunFindManyMock = jest . fn ( ) ,
2627 testRunCreateMock = jest . fn ( ) ,
28+ testRunCountMock = jest . fn ( ) ,
2729 getImageMock = jest . fn ( ) ,
2830 saveImageMock = jest . fn ( ) ,
2931 deleteImageMock = jest . fn ( ) ,
@@ -50,6 +52,7 @@ const initService = async ({
5052 findUnique : testRunFindUniqueMock ,
5153 create : testRunCreateMock ,
5254 update : testRunUpdateMock ,
55+ count : testRunCountMock ,
5356 } ,
5457 testVariation : {
5558 create : testVariationCreateMock ,
@@ -782,15 +785,53 @@ describe('TestRunsService', () => {
782785
783786 it ( 'findMany' , async ( ) => {
784787 const buildId = 'some id' ;
785- const testRunFindManyMock = jest . fn ( ) ;
788+ const testRun : TestRun = {
789+ id : '10fb5e02-64e0-4cf5-9f17-c00ab3c96658' ,
790+ imageName : '1592423768112.screenshot.png' ,
791+ diffName : 'diffName' ,
792+ diffPercent : 12 ,
793+ diffTollerancePercent : 1 ,
794+ pixelMisMatchCount : 123 ,
795+ status : 'new' ,
796+ buildId : buildId ,
797+ testVariationId : '3bc4a5bc-006e-4d43-8e4e-eaa132627fca' ,
798+ updatedAt : new Date ( ) ,
799+ createdAt : new Date ( ) ,
800+ name : 'ss2f77' ,
801+ browser : 'chromium' ,
802+ device : null ,
803+ os : null ,
804+ viewport : '1800x1600' ,
805+ baselineName : null ,
806+ ignoreAreas : '[]' ,
807+ tempIgnoreAreas : '[]' ,
808+ comment : 'some comment' ,
809+ baselineBranchName : 'master' ,
810+ branchName : 'develop' ,
811+ merge : false ,
812+ } ;
813+ const testRunFindManyMock = jest . fn ( ) . mockResolvedValueOnce ( [ testRun ] ) ;
814+ const testRunCountMock = jest . fn ( ) . mockResolvedValueOnce ( 30 ) ;
786815 service = await initService ( {
787816 testRunFindManyMock,
817+ testRunCountMock,
788818 } ) ;
789819
790- await service . findMany ( buildId ) ;
820+ const result = await service . findMany ( buildId , 10 , 1 ) ;
791821
792822 expect ( testRunFindManyMock ) . toHaveBeenCalledWith ( {
793823 where : { buildId } ,
824+ take : 10 ,
825+ skip : 1 ,
826+ } ) ;
827+ expect ( testRunCountMock ) . toHaveBeenCalledWith ( {
828+ where : { buildId } ,
829+ } ) ;
830+ expect ( result ) . toEqual ( {
831+ data : [ new TestRunDto ( testRun ) ] ,
832+ take : 10 ,
833+ skip : 1 ,
834+ total : 30 ,
794835 } ) ;
795836 } ) ;
796837
0 commit comments