Skip to content

Commit 2b196de

Browse files
authored
fix: exports (#26)
1 parent fb6a487 commit 2b196de

9 files changed

+87
-19
lines changed

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"description": "A BMP image decoder and encoder",
66
"author": "Daniel Kostro",
77
"type": "module",
8-
"exports": "./lib/index.js",
8+
"exports": {
9+
".": "./lib/index.js"
10+
},
911
"files": [
1012
"lib",
1113
"src"
@@ -28,15 +30,15 @@
2830
"iobuffer": "^6.0.0"
2931
},
3032
"devDependencies": {
31-
"@types/node": "^24.0.1",
32-
"@vitest/coverage-v8": "^3.2.3",
33-
"@zakodium/tsconfig": "^1.0.1",
34-
"eslint": "^9.29.0",
35-
"eslint-config-cheminfo-typescript": "^18.0.1",
36-
"prettier": "^3.5.3",
33+
"@types/node": "^24.2.1",
34+
"@vitest/coverage-v8": "^3.2.4",
35+
"@zakodium/tsconfig": "^1.0.2",
36+
"eslint": "^9.33.0",
37+
"eslint-config-cheminfo-typescript": "^19.0.0",
38+
"prettier": "^3.6.2",
3739
"rimraf": "^6.0.1",
38-
"typescript": "^5.8.3",
39-
"vitest": "^3.2.3"
40+
"typescript": "^5.9.2",
41+
"vitest": "^3.2.4"
4042
},
4143
"repository": {
4244
"type": "git",

src/__tests__/8bitChannelImages.read.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

33
import { decode } from '../index.ts';
44

@@ -9,6 +9,8 @@ import { testEncode } from './test_encode.ts';
99

1010
describe('decode image with bitDepth of 1', () => {
1111
it('decode a 2x2 RGBA image', () => {
12+
expect.assertions(1);
13+
1214
// R G
1315
// B W
1416
const data = createTestData({
@@ -27,6 +29,8 @@ describe('decode image with bitDepth of 1', () => {
2729
});
2830

2931
it('decode an RGB 5x1 image', () => {
32+
expect.assertions(1);
33+
3034
// R R R R R
3135
const data = createTestData({
3236
colorModel: 'RGB',
@@ -40,6 +44,8 @@ describe('decode image with bitDepth of 1', () => {
4044
});
4145

4246
it('decode a 1x6RGB image', () => {
47+
expect.assertions(1);
48+
4349
// R
4450
// G
4551
// B
@@ -65,6 +71,8 @@ describe('decode image with bitDepth of 1', () => {
6571
});
6672

6773
it('decode a 6x4 grey image', () => {
74+
expect.assertions(1);
75+
6876
const data = createTestData({
6977
colorModel: 'GREYSCALE',
7078
width: 6,
@@ -80,7 +88,10 @@ describe('decode image with bitDepth of 1', () => {
8088
});
8189
testDecode(data, '6x4Grey.bmp');
8290
});
91+
8392
it('checks BI_BITFIELDS compression decoding', () => {
93+
expect.assertions(1);
94+
8495
const imageData = decode(readTestFile('GIMP_images/ColorGrid5x5.bmp'));
8596
testEncode(imageData, 'ColorGrid5x5.bmp');
8697
});

src/__tests__/8bit_channel_images.compatibility.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,39 @@ describe('decode image with bit depth of 8', () => {
99
const buffer = readTestFile('GIMP_images/gray5x5.bmp');
1010
const imageResult = decode(buffer);
1111
const encodedImage = encode(imageResult);
12+
1213
expect(Buffer.from(encodedImage)).toStrictEqual(buffer);
1314
});
1415

1516
it('lena grayscale image', () => {
1617
const buffer = readTestFile('GIMP_images/lena.bmp');
1718
const imageResult = decode(buffer);
1819
const encodedImage = encode(imageResult);
20+
1921
expect(Buffer.from(encodedImage)).toStrictEqual(buffer);
2022
});
2123

2224
it('blackbuck RGB image', () => {
2325
const buffer = readTestFile('GIMP_images/blackbuck.bmp');
2426
const imageResult = decode(buffer);
2527
const encodedBuffer = encode(imageResult);
28+
2629
expect(Buffer.from(encodedBuffer)).toStrictEqual(buffer);
2730
});
2831

2932
it('simple RGB image to check color encoding', () => {
3033
const buffer = readTestFile('GIMP_images/bmp_24.bmp');
3134
const imageResult = decode(buffer);
3235
const encodedBuffer = encode(imageResult);
36+
3337
expect(Buffer.from(encodedBuffer)).toStrictEqual(buffer);
3438
});
3539

3640
it('5x5 color grid RGBA image', () => {
3741
const buffer = readTestFile('GIMP_images/ColorGrid5x5.bmp');
3842
const imageResult = decode(buffer);
3943
const encodedBuffer = encode(imageResult);
44+
4045
expect(Buffer.from(encodedBuffer)).toStrictEqual(buffer);
4146
});
4247
});

src/__tests__/8bit_channel_images.write.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { describe, it } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

33
import { createTestData } from './create_test_data.ts';
44
import { testEncode } from './test_encode.ts';
55

66
describe('decode image with bitDepth of 1', () => {
77
it('decode an RGBA 2x2 image', () => {
8+
expect.assertions(1);
9+
810
// R G
911
// B W
1012
const data = createTestData({
@@ -23,6 +25,8 @@ describe('decode image with bitDepth of 1', () => {
2325
});
2426

2527
it('decode an RGB 5x1 image', () => {
28+
expect.assertions(1);
29+
2630
// R R R R R
2731
const data = createTestData({
2832
colorModel: 'RGB',
@@ -36,6 +40,8 @@ describe('decode image with bitDepth of 1', () => {
3640
});
3741

3842
it('decode an RGB 1x6 image', () => {
43+
expect.assertions(1);
44+
3945
// R
4046
// G
4147
// B
@@ -61,6 +67,8 @@ describe('decode image with bitDepth of 1', () => {
6167
});
6268

6369
it('decode a 6x4 grey image', () => {
70+
expect.assertions(1);
71+
6472
const data = createTestData({
6573
colorModel: 'GREYSCALE',
6674
width: 6,

src/__tests__/binary_images.read.test.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { testDecode } from './test_decode.ts';
77

88
describe('decode image with bitDepth of 1', () => {
99
it('decode a 5x5 image', () => {
10+
expect.assertions(1);
11+
1012
// 0 0 0 0 0
1113
// 0 1 1 1 0
1214
// 0 1 0 1 0
@@ -30,6 +32,8 @@ describe('decode image with bitDepth of 1', () => {
3032
});
3133

3234
it('decode a 1x5 image', () => {
35+
expect.assertions(1);
36+
3337
// 0
3438
// 1
3539
// 0
@@ -46,6 +50,8 @@ describe('decode image with bitDepth of 1', () => {
4650
});
4751

4852
it('decode a 5x1 image', () => {
53+
expect.assertions(1);
54+
4955
// 1 0 1 0 0
5056
const data = createTestData({
5157
colorModel: 'BINARY',
@@ -57,6 +63,8 @@ describe('decode image with bitDepth of 1', () => {
5763
});
5864

5965
it('decode a 6x4 image', () => {
66+
expect.assertions(1);
67+
6068
const data = createTestData({
6169
colorModel: 'BINARY',
6270
width: 6,
@@ -74,6 +82,8 @@ describe('decode image with bitDepth of 1', () => {
7482
});
7583

7684
it('decode a 62x4', () => {
85+
expect.assertions(1);
86+
7787
const data = createTestData({
7888
colorModel: 'BINARY',
7989
width: 62,
@@ -107,9 +117,10 @@ describe('decode image with bitDepth of 1', () => {
107117
});
108118

109119
it('decode a 10x2 image', () => {
120+
expect.assertions(1);
121+
110122
// 1 1 1 0 0 1 0 1 0 1
111123
// 1 0 1 0 1 0 0 1 1 1
112-
113124
const data = createTestData({
114125
colorModel: 'BINARY',
115126
width: 10,
@@ -125,6 +136,8 @@ describe('decode image with bitDepth of 1', () => {
125136
});
126137

127138
it('decode image with exactly 4 bytes width', () => {
139+
expect.assertions(1);
140+
128141
const data = createTestData({
129142
colorModel: 'BINARY',
130143
width: 32,
@@ -146,6 +159,8 @@ describe('decode image with bitDepth of 1', () => {
146159
});
147160

148161
it('decode image with more that 4 bytes width', () => {
162+
expect.assertions(1);
163+
149164
const data = createTestData({
150165
colorModel: 'BINARY',
151166
width: 42,
@@ -167,6 +182,8 @@ describe('decode image with bitDepth of 1', () => {
167182
});
168183

169184
it('decode image where skipBit can equal relOffset on the last column', () => {
185+
expect.assertions(1);
186+
170187
const data = createTestData({
171188
colorModel: 'BINARY',
172189
width: 60,
@@ -216,6 +233,7 @@ describe('decode image with bitDepth of 1', () => {
216233
});
217234
const encodedImage = encode(data);
218235
const decodedData = decode(encodedImage);
219-
expect(decodedData).toEqual(data);
236+
237+
expect(decodedData).toStrictEqual(data);
220238
});
221239
});

src/__tests__/binary_images.write.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { testEncode } from './test_encode.ts';
77

88
describe('encode image with bitDepth of 1', () => {
99
it('encode a 5x5 image', () => {
10+
expect.assertions(1);
11+
1012
// 0 0 0 0 0
1113
// 0 1 1 1 0
1214
// 0 1 0 1 0
@@ -30,6 +32,8 @@ describe('encode image with bitDepth of 1', () => {
3032
});
3133

3234
it('encode a 1x5 image', () => {
35+
expect.assertions(1);
36+
3337
// 0
3438
// 1
3539
// 0
@@ -46,6 +50,8 @@ describe('encode image with bitDepth of 1', () => {
4650
});
4751

4852
it('encode a 5x1 image', () => {
53+
expect.assertions(1);
54+
4955
// 1 0 1 0 0
5056
const data = createTestData({
5157
colorModel: 'BINARY',
@@ -57,6 +63,8 @@ describe('encode image with bitDepth of 1', () => {
5763
});
5864

5965
it('encode a 6x4 image', () => {
66+
expect.assertions(1);
67+
6068
const data = createTestData({
6169
colorModel: 'BINARY',
6270
width: 6,
@@ -74,6 +82,8 @@ describe('encode image with bitDepth of 1', () => {
7482
});
7583

7684
it('encode a 62x4', () => {
85+
expect.assertions(1);
86+
7787
const data = createTestData({
7888
colorModel: 'BINARY',
7989
width: 62,
@@ -107,6 +117,8 @@ describe('encode image with bitDepth of 1', () => {
107117
});
108118

109119
it('encode a 10x2 image', () => {
120+
expect.assertions(1);
121+
110122
// 1 1 1 0 0 1 0 1 0 1
111123
// 1 0 1 0 1 0 0 1 1 1
112124
const data = createTestData({
@@ -123,6 +135,8 @@ describe('encode image with bitDepth of 1', () => {
123135
});
124136

125137
it('encode image with exactly 4 bytes width', () => {
138+
expect.assertions(1);
139+
126140
const data = createTestData({
127141
colorModel: 'BINARY',
128142
width: 32,
@@ -144,6 +158,8 @@ describe('encode image with bitDepth of 1', () => {
144158
});
145159

146160
it('encode image with more that 4 bytes width', () => {
161+
expect.assertions(1);
162+
147163
const data = createTestData({
148164
colorModel: 'BINARY',
149165
width: 42,
@@ -163,7 +179,10 @@ describe('encode image with bitDepth of 1', () => {
163179
});
164180
testEncode(data, '42x2.bmp');
165181
});
182+
166183
it('encode image where skipBit can equal relOffset on the last column', () => {
184+
expect.assertions(1);
185+
167186
const data = createTestData({
168187
colorModel: 'BINARY',
169188
width: 60,
@@ -196,6 +215,7 @@ describe('encode image with bitDepth of 1', () => {
196215

197216
testEncode(data, '60x4.bmp');
198217
});
218+
199219
it('encode image after decode must give the same image', () => {
200220
const data = createTestData({
201221
colorModel: 'BINARY',
@@ -229,10 +249,12 @@ describe('encode image with bitDepth of 1', () => {
229249
const encodedImage = encode(data);
230250
const decodedImage = decode(encodedImage);
231251

232-
expect(decodedImage).toEqual(data);
252+
expect(decodedImage).toStrictEqual(data);
233253
});
234254

235255
it('encode a 5x5 image without optional parameters', () => {
256+
expect.assertions(1);
257+
236258
const dataWithoutOptions = {
237259
width: 5,
238260
height: 5,

src/__tests__/errors.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'vitest';
1+
import { describe, expect, it, test } from 'vitest';
22

33
import { decode, encode } from '../index.ts';
44

@@ -67,6 +67,7 @@ describe('errors', () => {
6767
height: 5,
6868
data: new Uint8Array([1, 1, 1, 1, 1]),
6969
});
70+
7071
expect(() => {
7172
encode(data);
7273
}).toThrow(/Invalid data length./i);
@@ -106,6 +107,7 @@ describe('errors', () => {
106107
data: new Uint8Array([1, 1, 1, 1]),
107108
colorMasks: [0x0, 0x10, 0x56],
108109
});
110+
109111
expect(() => {
110112
encode(data);
111113
}).toThrow(
@@ -114,7 +116,7 @@ describe('errors', () => {
114116
});
115117
});
116118

117-
it('should throw if colorModel is invalid for test data', () => {
119+
test('should throw if colorModel is invalid for test data', () => {
118120
expect(() => {
119121
createTestData({
120122
//@ts-expect-error Invalid color model.

0 commit comments

Comments
 (0)