@@ -35,7 +35,11 @@ describe("libnut screen action", () => {
35
35
bytesPerPixel : 0 ,
36
36
colorAt : jest . fn ( ) ,
37
37
height : screenShotSize . height ,
38
- image : new ArrayBuffer ( 0 ) ,
38
+ image : Buffer . from (
39
+ new Array ( screenShotSize . width * screenShotSize . height * 4 + 10 ) . fill (
40
+ 0
41
+ )
42
+ ) ,
39
43
width : screenShotSize . width ,
40
44
} ) ) ;
41
45
libnut . getScreenSize = jest . fn ( ( ) => ( {
@@ -51,6 +55,9 @@ describe("libnut screen action", () => {
51
55
expect ( image . height ) . toEqual ( screenShotSize . height ) ;
52
56
expect ( image . pixelDensity . scaleX ) . toEqual ( 2 ) ;
53
57
expect ( image . pixelDensity . scaleY ) . toEqual ( 2 ) ;
58
+ expect ( image . data . length ) . toEqual (
59
+ screenShotSize . width * screenShotSize . height * 4
60
+ ) ;
54
61
expect ( libnut . screen . capture ) . toBeCalledTimes ( 1 ) ;
55
62
} ) ;
56
63
@@ -64,7 +71,11 @@ describe("libnut screen action", () => {
64
71
bytesPerPixel : 0 ,
65
72
colorAt : jest . fn ( ) ,
66
73
height : screenShotSize . height ,
67
- image : new ArrayBuffer ( 0 ) ,
74
+ image : Buffer . from (
75
+ new Array ( screenShotSize . width * screenShotSize . height * 4 + 10 ) . fill (
76
+ 0
77
+ )
78
+ ) ,
68
79
width : screenShotSize . width ,
69
80
} ) ) ;
70
81
@@ -76,6 +87,9 @@ describe("libnut screen action", () => {
76
87
expect ( image . height ) . toEqual ( screenShotSize . height ) ;
77
88
expect ( image . pixelDensity . scaleX ) . toEqual ( 20 ) ;
78
89
expect ( image . pixelDensity . scaleY ) . toEqual ( 20 ) ;
90
+ expect ( image . data . length ) . toEqual (
91
+ screenShotSize . width * screenShotSize . height * 4
92
+ ) ;
79
93
expect ( libnut . screen . capture ) . toBeCalledTimes ( 1 ) ;
80
94
} ) ;
81
95
0 commit comments