@@ -49,6 +49,10 @@ export const CustomMatchers = {
49
49
toHavePixelWithColor : ( ( image : IMagickImage , x : number , y : number , colorOrString : IMagickColor | string ) => {
50
50
const actualColor = pixelColor ( image , x , y ) ;
51
51
let expectedColor = colorOrString . toString ( ) ;
52
+ if ( expectedColor . length === 4 )
53
+ {
54
+ expectedColor = '#' + expectedColor [ 1 ] + expectedColor [ 1 ] + expectedColor [ 2 ] + expectedColor [ 2 ] + expectedColor [ 3 ] + expectedColor [ 3 ] ;
55
+ }
52
56
if ( expectedColor . length === 7 )
53
57
expectedColor += 'ff' ;
54
58
@@ -86,16 +90,22 @@ function pixelColor(image: IMagickImage, x: number, y: number): string {
86
90
87
91
switch ( channelCount ) {
88
92
case 1 :
89
- result += toHex ( pixel [ 0 ] ) ;
90
- result += toHex ( Quantum . max ) ;
91
- break ;
92
- case 2 :
93
- result += toHex ( pixel [ image . _channelOffset ( PixelChannel . Red ) ] ) ;
94
- if ( image . hasAlpha )
95
- result += toHex ( pixel [ image . _channelOffset ( PixelChannel . Alpha ) ] ) ;
96
- else
93
+ {
94
+ const value = toHex ( pixel [ 0 ] ) ;
95
+ result += value + value + value ;
97
96
result += toHex ( Quantum . max ) ;
98
- break ;
97
+ break ;
98
+ }
99
+ case 2 :
100
+ {
101
+ const value = toHex ( pixel [ image . _channelOffset ( PixelChannel . Red ) ] ) ;
102
+ result += value + value + value ;
103
+ if ( image . hasAlpha )
104
+ result += toHex ( pixel [ image . _channelOffset ( PixelChannel . Alpha ) ] ) ;
105
+ else
106
+ result += toHex ( Quantum . max ) ;
107
+ break ;
108
+ }
99
109
case 3 :
100
110
result += toHex ( pixel [ image . _channelOffset ( PixelChannel . Red ) ] ) ;
101
111
result += toHex ( pixel [ image . _channelOffset ( PixelChannel . Green ) ] ) ;
0 commit comments