Skip to content

Commit 5097e88

Browse files
test(NODE-6586): add regression test to ensure compressionLevel works (#46)
1 parent 6e6fb45 commit 5097e88

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

test/index.test.js

+119
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ describe('decompress', function () {
3333
});
3434

3535
describe('compress', function () {
36+
test('compress() supports compressionLevel', async function () {
37+
const buffer = Buffer.from(historyFile());
38+
const unspecified = await compress(buffer);
39+
const specified = await compress(buffer, 22);
40+
41+
expect(specified.length).to.be.lessThan(unspecified.length);
42+
});
3643
test('compress() throws a TypeError', async function () {
3744
expect(await compress().catch(e => e))
3845
.to.be.instanceOf(TypeError)
@@ -81,3 +88,115 @@ function testSuite(decompress, compress) {
8188
});
8289
};
8390
}
91+
92+
/**
93+
* This function returns a string that, when compressed with compression level 22,
94+
* compresses smaller than the default level 3. This is used to ensure that we handle
95+
* the compression level option.
96+
*/
97+
function historyFile() {
98+
return `
99+
# Changelog
100+
101+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
102+
103+
## [v2.0.0-alpha.0](https://github.com/mongodb-js/zstd/compare/v1.2.2...v2.0.0-alpha.0) (2024-11-27)
104+
105+
### Features
106+
107+
* **NODE-4569:** add "musl" builds for Alpine Linux ([#12](https://github.com/mongodb-js/zstd/issues/12)) ([b3dedc3](https://github.com/mongodb-js/zstd/commit/b3dedc31a274df1eecb54b9092c8dd270f31c21c))
108+
* **NODE-6539:** add base napi C++ template with standard Node team tooling ([#28](https://github.com/mongodb-js/zstd/issues/28)) ([8c40b08](https://github.com/mongodb-js/zstd/commit/8c40b08782969c87b85d5d1bea0a753db73cc87f))
109+
* **NODE-6540:** Add c++ zstd compression API ([#30](https://github.com/mongodb-js/zstd/issues/30)) ([6673245](https://github.com/mongodb-js/zstd/commit/667324522600abc6f731b54a9d9a7c6e92954bef))
110+
* **NODE-6588:** add ssdlc to zstd ([#43](https://github.com/mongodb-js/zstd/issues/43)) ([016d857](https://github.com/mongodb-js/zstd/commit/016d857ccb76f01ebaf18e01756b571338723a16))
111+
112+
### [1.2.2](https://github.com/mongodb-js/zstd/compare/v1.2.1...v1.2.2) (2024-09-16)
113+
114+
115+
### Bug Fixes
116+
117+
* **NODE-6381:** use targeting for x86_64 darwin ([#26](https://github.com/mongodb-js/zstd/issues/26)) ([f95c9f6](https://github.com/mongodb-js/zstd/commit/f95c9f6b1e836cce7da4e6955181261110e88487))
118+
119+
### [1.2.1](https://github.com/mongodb-js/zstd/compare/v1.2.0...v1.2.1) (2024-09-06)
120+
121+
122+
### Bug Fixes
123+
124+
* **NODE-6348:** Wrap thrown errors in JS Error objects with stacks ([#25](https://github.com/mongodb-js/zstd/issues/25)) ([af62c4f](https://github.com/mongodb-js/zstd/commit/af62c4f5f816386ce605c20641ad30cc74bb77e2))
125+
126+
## [1.2.0](https://github.com/mongodb-js/zstd/compare/v1.1.0...v1.2.0) (2023-08-29)
127+
128+
129+
### Bug Fixes
130+
131+
* **NODE-5177:** update to latest zstd-sys ([#15](https://github.com/mongodb-js/zstd/issues/15)) ([6b6d8ce](https://github.com/mongodb-js/zstd/commit/6b6d8ce098de757c53fd52a09d47aa3e29ed2902))
132+
133+
## [1.1.0](https://github.com/mongodb-js/zstd/compare/v1.0.0...v1.1.0) (2023-01-23)
134+
135+
136+
### Features
137+
138+
* **NODE-4569:** add "musl" builds for Alpine Linux ([#12](https://github.com/mongodb-js/zstd/issues/12)) ([b3dedc3](https://github.com/mongodb-js/zstd/commit/b3dedc31a274df1eecb54b9092c8dd270f31c21c))
139+
140+
## [1.0.0](https://github.com/mongodb-js/zstd/compare/v0.0.7...v1.0.0) (2022-05-18)
141+
142+
### [0.0.7](https://github.com/mongodb-js/zstd/compare/v0.0.6...v0.0.7) (2022-05-18)
143+
144+
145+
### Bug Fixes
146+
147+
* fix macos arm64 build ([#9](https://github.com/mongodb-js/zstd/issues/9)) ([1ebefde](https://github.com/mongodb-js/zstd/commit/1ebefdedb761b34bcc721a934296d3ac9f0e7a1b))
148+
149+
### [0.0.6](https://github.com/mongodb-js/zstd/compare/v0.0.5...v0.0.6) (2022-05-18)
150+
151+
152+
### Features
153+
154+
* add readme ([833aa92](https://github.com/mongodb-js/zstd/commit/833aa92213236ef35c4bd79d4c462751a3b4e634))
155+
* update readme ([49ac44e](https://github.com/mongodb-js/zstd/commit/49ac44efbe9a4ab544958b97ae178b51cac057ff))
156+
157+
### [0.0.5](https://github.com/mongodb-js/zstd/compare/v0.0.4...v0.0.5) (2022-05-09)
158+
159+
160+
### Bug Fixes
161+
162+
* remove 686 win build ([ea36ddc](https://github.com/mongodb-js/zstd/commit/ea36ddc0ce3e6630321e7074a138f2d45dd16f4f))
163+
164+
### [0.0.4](https://github.com/mongodb-js/zstd/compare/v0.0.3...v0.0.4) (2022-05-06)
165+
166+
167+
### Features
168+
169+
* **NODE-1837:** support passing compression level ([2c1a917](https://github.com/mongodb-js/zstd/commit/2c1a9171c689c1fc87428d383ffeb823291f84cf))
170+
171+
### [0.0.3](https://github.com/mongodb-js/zstd/compare/v0.0.2...v0.0.3) (2022-05-06)
172+
173+
174+
### Bug Fixes
175+
176+
* update publish task regex ([b62d9b0](https://github.com/mongodb-js/zstd/commit/b62d9b0e644c85d3443f738d953ae7816d3eba00))
177+
178+
### [0.0.2](https://github.com/mongodb-js/zstd/compare/v0.0.1...v0.0.2) (2022-05-06)
179+
180+
181+
### Bug Fixes
182+
183+
* dont use org in napi name ([9063ea8](https://github.com/mongodb-js/zstd/commit/9063ea8bb7b187aacd876f75b3e74bc0188e7a2b))
184+
185+
### 0.0.1 (2022-05-05)
186+
187+
188+
### Features
189+
190+
* add release script ([c2c1783](https://github.com/mongodb-js/zstd/commit/c2c1783242766c8b65f57838494d1a3c4dc23305))
191+
* add standard version ([f63a9b9](https://github.com/mongodb-js/zstd/commit/f63a9b95ba261004cb2f481ff201fa2e116d3aed))
192+
* initial project setup ([53671a3](https://github.com/mongodb-js/zstd/commit/53671a393326605650d3ae12959796a6c6976472))
193+
* update package.json files ([7823f1b](https://github.com/mongodb-js/zstd/commit/7823f1b3156f4eacd2c235ac660aa9810eee6f84))
194+
* update to idomatic rust ([16e215a](https://github.com/mongodb-js/zstd/commit/16e215a59817fdf94bb62c8620b49b6255bafda0))
195+
196+
197+
### Bug Fixes
198+
199+
* handle status in error ([e29c0ed](https://github.com/mongodb-js/zstd/commit/e29c0ed3b1077987c28bc4daa11c5d6a01c650cf))
200+
* remove debug js ([c454785](https://github.com/mongodb-js/zstd/commit/c454785a6cbfe63ed21ca3942ce0707e0b399d3f))
201+
`;
202+
}

0 commit comments

Comments
 (0)