Skip to content

Commit 28a42c2

Browse files
committed
Add tests for compression
1 parent aad68a6 commit 28a42c2

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Use Node.js
1818
uses: actions/setup-node@v4
1919
with:
20-
node-version: 16.x
20+
node-version: 18.x
2121

2222
- name: Run tests
2323
run: npm install && npx jest

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"scripts": {
77
"test": "jest --watch"
88
},
9+
"engines" : {
10+
"node" : ">=18.0.0"
11+
},
912
"keywords": [],
1013
"author": "",
1114
"license": "ISC",

tests/test-encoding.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { decode, encodeWithJson, encodeWithV1, encodeWithV2 } from "../src/encoding";
1+
import { decode, encodeWithJson, encodeWithJsonz, encodeWithV1, encodeWithV2 } from "../src/encoding";
22

33

44
const exampleTwelf = `
@@ -11,15 +11,16 @@ describe('url encoding', () => {
1111
expect(await decode(encodeWithV1(exampleTwelf))).toEqual({ t: 'setTextAndExec', text: exampleTwelf });
1212
});
1313

14+
test('should roundtrip with v2', async () => {
15+
expect(await decode(await encodeWithV2(exampleTwelf))).toEqual({ t: 'setTextAndExec', text: exampleTwelf });
16+
});
17+
1418
test('should roundtrip with json', async () => {
1519
expect(await decode(encodeWithJson({ t: 'setTextAndExec', text: exampleTwelf }))).toEqual({ t: 'setTextAndExec', text: exampleTwelf });
1620
});
1721

18-
// I'd like to test v2 in nodejs, but I need to figure out a strategy
19-
// for polyfilling Blob and CompressionStream
20-
21-
// test('should roundtrip with v2', async () => {
22-
// expect(await decode(await encodeWithV2(exampleTwelf))).toEqual({ t: 'setTextAndExec', text: exampleTwelf});
23-
// });
22+
test('should roundtrip with jsonz', async () => {
23+
expect(await decode(await encodeWithJsonz({ t: 'setTextAndExec', text: exampleTwelf }))).toEqual({ t: 'setTextAndExec', text: exampleTwelf });
24+
});
2425

2526
});

0 commit comments

Comments
 (0)