@@ -605,24 +605,27 @@ describe('hermione test adapter', () => {
605605 } ) ;
606606
607607 describe ( 'expected path' , ( ) => {
608- let lastImageInfo ;
609-
610- beforeEach ( ( ) => {
611- lastImageInfo = [ {
608+ const mkLastImageInfo_ = ( opts = { } ) => {
609+ const { stateName, expectedImgPath} = _ . defaults ( opts , {
612610 stateName : 'plain' ,
611+ expectedImgPath : 'default/expected/img/path.png'
612+ } ) ;
613+
614+ return [ {
615+ stateName,
613616 expectedImg : {
614- path : ' expectedImgPath'
617+ path : expectedImgPath
615618 }
616619 } ] ;
617- } ) ;
620+ } ;
618621
619622 it ( 'should be pulled from the database if exists' , async ( ) => {
620623 sqliteAdapter . query . withArgs ( {
621624 select : 'imagesInfo' ,
622625 where : 'suitePath = ? AND name = ?' ,
623626 orderBy : 'timestamp' ,
624627 orderDescending : true
625- } ) . returns ( { imagesInfo : JSON . stringify ( lastImageInfo ) } ) ;
628+ } ) . returns ( { imagesInfo : JSON . stringify ( mkLastImageInfo_ ( ) ) } ) ;
626629
627630 const testResult = mkTestResult_ ( {
628631 fullTitle : ( ) => 'some-title' ,
@@ -651,7 +654,7 @@ describe('hermione test adapter', () => {
651654 } ) ;
652655
653656 it ( 'should be generated on update' , async ( ) => {
654- sqliteAdapter . query . returns ( { imagesInfo : JSON . stringify ( lastImageInfo ) } ) ;
657+ sqliteAdapter . query . returns ( { imagesInfo : JSON . stringify ( mkLastImageInfo_ ( ) ) } ) ;
655658 const testResult = mkTestResult_ ( {
656659 fullTitle : ( ) => 'some-title' ,
657660 assertViewResults : [ mkErrStub ( ) ] ,
@@ -664,8 +667,20 @@ describe('hermione test adapter', () => {
664667 assert . calledOnce ( utils . getReferencePath ) ;
665668 } ) ;
666669
670+ it ( 'should be queried from the database for each browser' , async ( ) => {
671+ const chromeTestResult = mkTestResult_ ( { browserId : 'chrome' } ) ;
672+ const firefoxTestResult = mkTestResult_ ( { browserId : 'firefox' } ) ;
673+
674+ mkHermioneTestResultAdapter ( chromeTestResult , { status : FAIL } ) . getImagesFor ( FAIL , 'plain' ) ;
675+ mkHermioneTestResultAdapter ( firefoxTestResult , { status : FAIL } ) . getImagesFor ( FAIL , 'plain' ) ;
676+
677+ assert . calledTwice ( sqliteAdapter . query ) ;
678+ assert . calledWith ( sqliteAdapter . query . firstCall , sinon . match . any , sinon . match . any , 'chrome' ) ;
679+ assert . calledWith ( sqliteAdapter . query . secondCall , sinon . match . any , sinon . match . any , 'firefox' ) ;
680+ } ) ;
681+
667682 it ( 'should be queried from the database once per state' , async ( ) => {
668- sqliteAdapter . query . returns ( { imagesInfo : JSON . stringify ( lastImageInfo ) } ) ;
683+ sqliteAdapter . query . returns ( { imagesInfo : JSON . stringify ( mkLastImageInfo_ ( ) ) } ) ;
669684 const testResult = mkTestResult_ ( {
670685 fullTitle : ( ) => 'some-title' ,
671686 assertViewResults : [ mkErrStub ( ) ] ,
0 commit comments