@browsercore/testing 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Test Category 9 — Compression.
3
3
  *
4
- * Verify gzip, brotli, deflate decoding behavior. See docs/TEST-SUITE.md
5
- * ("Test Category 9 — Compression") for full acceptance criteria.
4
+ * Verify gzip, brotli, deflate decoding behavior matches the Node.js reference
5
+ * oracle (`nodeZlib`). The system under test is `@browsercore/compression`;
6
+ * `nodeZlib` is the spec reference for these primitive layers. See
7
+ * docs/TEST-SUITE.md ("Test Category 9 — Compression") for full acceptance
8
+ * criteria.
6
9
  */
7
10
  export declare const CATEGORY_ID: "compression";
8
11
  //# sourceMappingURL=compression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../src/categories/compression.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,eAAO,MAAM,WAAW,eAA2B,CAAC"}
1
+ {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../src/categories/compression.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,eAAO,MAAM,WAAW,eAA2B,CAAC"}
@@ -1,15 +1,63 @@
1
1
  /**
2
2
  * Test Category 9 — Compression.
3
3
  *
4
- * Verify gzip, brotli, deflate decoding behavior. See docs/TEST-SUITE.md
5
- * ("Test Category 9 — Compression") for full acceptance criteria.
4
+ * Verify gzip, brotli, deflate decoding behavior matches the Node.js reference
5
+ * oracle (`nodeZlib`). The system under test is `@browsercore/compression`;
6
+ * `nodeZlib` is the spec reference for these primitive layers. See
7
+ * docs/TEST-SUITE.md ("Test Category 9 — Compression") for full acceptance
8
+ * criteria.
6
9
  */
7
- import { describe, it } from "vitest";
10
+ import { deflateRawSync } from "node:zlib";
11
+ import { describe, expect, it } from "vitest";
12
+ import { compression, UnsupportedEncodingError, } from "@browsercore/compression";
13
+ import { nodeZlib } from "../reference/node-reference.js";
8
14
  import { TestCategory } from "../types.js";
9
15
  export const CATEGORY_ID = TestCategory.Compression;
16
+ /** Deterministic payload: byte[i] = i % 256 (reproducible, never random). */
17
+ function detBuffer(length) {
18
+ const bytes = new Uint8Array(length);
19
+ for (let i = 0; i < length; i++) {
20
+ bytes[i] = i % 256;
21
+ }
22
+ return bytes;
23
+ }
10
24
  describe(CATEGORY_ID, () => {
11
- it.todo("gzip decoding matches reference");
12
- it.todo("brotli decoding matches reference");
13
- it.todo("deflate decoding matches reference");
25
+ const payload = detBuffer(1024);
26
+ it("gzip decoding matches reference", () => {
27
+ const compressed = nodeZlib.gzip(payload);
28
+ const ours = compression.gunzip(compressed);
29
+ const theirs = nodeZlib.gunzip(compressed);
30
+ expect(ours).toEqual(theirs);
31
+ expect(ours).toEqual(payload);
32
+ });
33
+ it("brotli decoding matches reference", () => {
34
+ const compressed = nodeZlib.brotliCompress(payload);
35
+ const ours = compression.brotliDecompress(compressed);
36
+ const theirs = nodeZlib.brotliDecompress(compressed);
37
+ expect(ours).toEqual(theirs);
38
+ expect(ours).toEqual(payload);
39
+ });
40
+ it("deflate decoding matches reference (zlib-wrapped)", () => {
41
+ const compressed = nodeZlib.deflate(payload);
42
+ const ours = compression.inflate(compressed);
43
+ const theirs = nodeZlib.inflate(compressed);
44
+ expect(ours).toEqual(theirs);
45
+ expect(ours).toEqual(payload);
46
+ });
47
+ it("deflate decoding falls back to raw inflate", () => {
48
+ // A genuinely raw deflate stream (no zlib header) — inflateSync
49
+ // rejects it, so decompress() must fall back to raw inflate. Built
50
+ // with node:zlib's deflateRawSync, the only decoder that accepts it.
51
+ const raw = new Uint8Array(deflateRawSync(payload));
52
+ expect(compression.decompress(raw, "deflate")).toEqual(payload);
53
+ });
54
+ it("decompress() dispatches on the content-encoding token", () => {
55
+ expect(compression.decompress(nodeZlib.gzip(payload), "gzip")).toEqual(payload);
56
+ expect(compression.decompress(nodeZlib.deflate(payload), "deflate")).toEqual(payload);
57
+ expect(compression.decompress(nodeZlib.brotliCompress(payload), "br")).toEqual(payload);
58
+ });
59
+ it("decompress() rejects an unsupported encoding", () => {
60
+ expect(() => compression.decompress(payload, "zstd")).toThrow(UnsupportedEncodingError);
61
+ });
14
62
  });
15
63
  //# sourceMappingURL=compression.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compression.js","sourceRoot":"","sources":["../../src/categories/compression.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;AAEpD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC3C,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAC7C,EAAE,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;AAClD,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"compression.js","sourceRoot":"","sources":["../../src/categories/compression.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACH,WAAW,EACX,wBAAwB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;AAEpD,6EAA6E;AAC7E,SAAS,SAAS,CAAC,MAAc;IAC7B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC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AC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@browsercore/testing",
3
- "version": "0.1.2",
4
- "description": "Protocol verification — RFC compliance tests, browser golden packet captures, integration tests, and benchmarking.",
3
+ "version": "0.1.3",
4
+ "description": "Protocol verification \u2014 RFC compliance tests, browser golden packet captures, integration tests, and benchmarking.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/jverneuer/browsercore-testing.git"
@@ -20,7 +20,11 @@
20
20
  "import": "./dist/index.js"
21
21
  }
22
22
  },
23
- "files": ["dist", "LICENSE", "README.md"],
23
+ "files": [
24
+ "dist",
25
+ "LICENSE",
26
+ "README.md"
27
+ ],
24
28
  "publishConfig": {
25
29
  "access": "public",
26
30
  "registry": "https://registry.npmjs.org/"
@@ -41,6 +45,7 @@
41
45
  "node": ">=24.0.0"
42
46
  },
43
47
  "dependencies": {
48
+ "@browsercore/compression": "latest",
44
49
  "@browsercore/cookies": "latest",
45
50
  "@browsercore/crypto": "latest",
46
51
  "@browsercore/fetch": "latest",