@@ -14,38 +14,46 @@ afterEach(() => {
14
14
15
15
describe ( "Image class" , ( ) => {
16
16
it ( "should return alphachannel = true for > 3 channels" , ( ) => {
17
- const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 4 , "id" ) ;
17
+ const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 4 , "id" , 4 , 200 * 4 ) ;
18
18
expect ( SUT . hasAlphaChannel ) . toBeTruthy ( ) ;
19
19
} ) ;
20
20
21
21
it ( "should return alphachannel = false for <= 3 channels" , ( ) => {
22
- const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 3 , "id" ) ;
22
+ const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 3 , "id" , 4 , 200 * 4 ) ;
23
23
expect ( SUT . hasAlphaChannel ) . toBeFalsy ( ) ;
24
24
} ) ;
25
25
it ( "should return alphachannel = false for <= 3 channels" , ( ) => {
26
- const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 2 , "id" ) ;
26
+ const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 2 , "id" , 4 , 200 * 4 ) ;
27
27
expect ( SUT . hasAlphaChannel ) . toBeFalsy ( ) ;
28
28
} ) ;
29
29
it ( "should return alphachannel = false for <= 3 channels" , ( ) => {
30
- const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 1 , "id" ) ;
30
+ const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 1 , "id" , 4 , 200 * 4 ) ;
31
31
expect ( SUT . hasAlphaChannel ) . toBeFalsy ( ) ;
32
32
} ) ;
33
33
34
34
it ( "should throw for <= 0 channels" , ( ) => {
35
- expect ( ( ) => new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 0 , "id" ) ) . toThrowError (
36
- "Channel <= 0"
37
- ) ;
35
+ expect (
36
+ ( ) => new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 0 , "id" , 4 , 200 * 4 )
37
+ ) . toThrowError ( "Channel <= 0" ) ;
38
38
} ) ;
39
39
40
40
it ( "should have a default pixel density of 1.0" , ( ) => {
41
- const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 1 , "id" ) ;
41
+ const SUT = new Image ( 200 , 200 , Buffer . from ( [ 123 ] ) , 1 , "id" , 4 , 200 * 4 ) ;
42
42
expect ( SUT . pixelDensity ) . toEqual ( { scaleX : 1.0 , scaleY : 1.0 } ) ;
43
43
} ) ;
44
44
45
45
describe ( "Colormode" , ( ) => {
46
46
it ( "should not try to convert an image to BGR if it already has the correct color mode" , async ( ) => {
47
47
// GIVEN
48
- const bgrImage = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 , "testImage" ) ;
48
+ const bgrImage = new Image (
49
+ 100 ,
50
+ 100 ,
51
+ Buffer . from ( [ ] ) ,
52
+ 3 ,
53
+ "testImage" ,
54
+ 4 ,
55
+ 200 * 4
56
+ ) ;
49
57
50
58
// WHEN
51
59
const convertedImage = await bgrImage . toBGR ( ) ;
@@ -63,6 +71,8 @@ describe("Image class", () => {
63
71
Buffer . from ( [ ] ) ,
64
72
3 ,
65
73
"testImage" ,
74
+ 4 ,
75
+ 200 * 4 ,
66
76
ColorMode . RGB
67
77
) ;
68
78
@@ -78,7 +88,7 @@ describe("Image class", () => {
78
88
describe ( "isImage typeguard" , ( ) => {
79
89
it ( "should identify an Image" , ( ) => {
80
90
// GIVEN
81
- const img = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 4 , "foo" ) ;
91
+ const img = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 4 , "foo" , 4 , 200 * 4 ) ;
82
92
83
93
// WHEN
84
94
const result = isImage ( img ) ;
0 commit comments