Skip to content

Commit f5b709d

Browse files
committed
Add a test for obvious memory leaks/issues after repeated executions
1 parent a4012c6 commit f5b709d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/brotli.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ describe("Brotli-wasm", () => {
6060
expect(textDecoder.decode(result)).to.equal('Brotli brotli brotli brotli');
6161
});
6262

63+
it("can compress and decompress data many times", function () {
64+
this.timeout(10000); // Should only take 2-4 seconds, but leave some slack
65+
66+
const input = textEncoder.encode("Test input data");
67+
68+
for (let i = 0; i < 500; i++) {
69+
const compressed = brotli.compress(input);
70+
expect(dataToBase64(compressed)).to.equal('Gw4A+KWpyubolCCjVAjmxJ4D');
71+
72+
const decompressed = brotli.decompress(compressed);
73+
expect(textDecoder.decode(decompressed)).to.equal('Test input data');
74+
}
75+
});
76+
6377
it("cleanly fails when options is something other than an object", () => {
6478
const input = textEncoder.encode("Test input data");
6579
expect(() =>

0 commit comments

Comments
 (0)