@@ -669,17 +669,17 @@ function getPageNumber(screenshotName: string): string {
669669
670670export function validateCoordinates (
671671 coordString : string ,
672- viewportSize : { width : number , height : number } ,
673- snapshotName : string ,
674- viewportString : string
672+ pageHeight : number ,
673+ pageWidth : number ,
674+ snapshotName : string
675675) : { valid : boolean , error ?: string , coords ?: { top : number , bottom : number , left : number , right : number } } {
676676
677677 const coords = coordString . split ( ',' ) . map ( Number ) ;
678678
679679 if ( coords . length !== 4 ) {
680680 return {
681681 valid : false ,
682- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , invalid coordinates format: ${ coordString } . Expected: top,bottom,left,right`
682+ error : `for snapshot ${ snapshotName } , invalid coordinates format: ${ coordString } . Expected: top,bottom,left,right`
683683 } ;
684684 }
685685
@@ -688,42 +688,42 @@ export function validateCoordinates(
688688 if ( coords . some ( isNaN ) ) {
689689 return {
690690 valid : false ,
691- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , invalid coordinate values: ${ coordString } . All values must be numbers`
691+ error : `for snapshot ${ snapshotName } , invalid coordinate values: ${ coordString } . All values must be numbers`
692692 } ;
693693 }
694694
695695 if ( top < 0 || left < 0 || bottom < 0 || right < 0 ) {
696696 return {
697697 valid : false ,
698- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , invalid coordinate bounds: ${ coordString } . top,left,bottom,right must be >= 0`
698+ error : `for snapshot ${ snapshotName } , invalid coordinate bounds: ${ coordString } . top,left,bottom,right must be >= 0`
699699 } ;
700700 }
701701
702702 if ( top >= bottom ) {
703703 return {
704704 valid : false ,
705- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , invalid coordinate bounds: ${ coordString } . top must be < bottom`
705+ error : `for snapshot ${ snapshotName } , invalid coordinate bounds: ${ coordString } . top must be < bottom`
706706 } ;
707707 }
708708
709709 if ( left >= right ) {
710710 return {
711711 valid : false ,
712- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , invalid coordinate bounds: ${ coordString } . left must be < right`
712+ error : `for snapshot ${ snapshotName } , invalid coordinate bounds: ${ coordString } . left must be < right`
713713 } ;
714714 }
715715
716- if ( bottom > viewportSize . height ) {
716+ if ( bottom > pageHeight ) {
717717 return {
718718 valid : false ,
719- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , coordinates exceed viewport bounds: ${ coordString } . bottom (${ bottom } ) exceeds viewport height (${ viewportSize . height } )`
719+ error : `for snapshot ${ snapshotName } , coordinates exceed viewport bounds: ${ coordString } . bottom (${ bottom } ) exceeds viewport height (${ pageHeight } )`
720720 } ;
721721 }
722722
723- if ( right > viewportSize . width ) {
723+ if ( right > pageWidth ) {
724724 return {
725725 valid : false ,
726- error : `for snapshot ${ snapshotName } viewport ${ viewportString } , coordinates exceed viewport bounds: ${ coordString } . right (${ right } ) exceeds viewport width (${ viewportSize . width } )`
726+ error : `for snapshot ${ snapshotName } , coordinates exceed viewport bounds: ${ coordString } . right (${ right } ) exceeds viewport width (${ pageWidth } )`
727727 } ;
728728 }
729729
0 commit comments