Skip to content

Commit

Permalink
Add Bun test
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jun 20, 2024
1 parent d4c1b48 commit 0684c33
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ jobs:
- run: npm run bundle-and-test

e2e-tests:
name: E2E tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node ${{ env.PRIMARY_NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.PRIMARY_NODEJS_VERSION }}
cache: "npm"
- run: npm ci
- run: npm run transpile
- run: npm run bundle
- run: npm run test:e2e
name: E2E tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node ${{ env.PRIMARY_NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.PRIMARY_NODEJS_VERSION }}
cache: "npm"
- run: npm ci
- run: npm run transpile
- run: npm run bundle
- run: npm run test:e2e

unit-tests:
name: Unit tests
Expand Down Expand Up @@ -115,3 +115,26 @@ jobs:
- run: npm run transpile
- run: npm run test
- run: npm run test:cjs

test-bun:
name: Bun test
runs-on: ubuntu-latest
strategy:
matrix:
bun_version:
- 1.1.15

steps:
- uses: actions/checkout@v4
- name: Setup node ${{ env.PRIMARY_NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.PRIMARY_NODEJS_VERSION }}
cache: "npm"
- name: Setup Bun ${{ matrix.bun_version }}
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun_version }}
- run: npm ci
- run: npm run transpile
- run: bun test
20 changes: 10 additions & 10 deletions src/parse-chunked.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,43 +130,43 @@ describe('parseChunked()', () => {
it('abs pos across chunks', () =>
assert.rejects(
async () => await parse(['{"test":"he', 'llo",}']),
/(Unexpected token \}|Expected double-quoted property name) in JSON at position 16/
/(Unexpected token \}|Expected double-quoted property name) in JSON at position 16|Property name must be a string literal/
)
);
it('abs pos across chunks #2', () =>
assert.rejects(
async () => await parse(['[{"test":"hello"},', ',}']),
/Unexpected token , in JSON at position 18|Unexpected token ',', "\[,}" is not valid JSON$/
/Unexpected token , in JSON at position 18|Unexpected token ','(, "\[,}" is not valid JSON)?$|/
)
);
it('abs pos across chunks #3 (whitespaces)', () =>
assert.rejects(
async () => await parse(['[{"test" ', ' ', ' :"hello"} ', ' ', ',', ' ', ',}']),
/Unexpected token , in JSON at position 24|Unexpected token ',', "\[,}" is not valid JSON$/
/Unexpected token , in JSON at position 24|Unexpected token ','(, "\[,}" is not valid JSON)?$/
)
);
it('should fail when starts with a comma', () =>
assert.rejects(
async () => await parse([',{}']),
/Unexpected token , in JSON at position 0|Unexpected token ',', ",{}" is not valid JSON$/
/Unexpected token , in JSON at position 0|Unexpected token ','(, ",{}" is not valid JSON)?$/
)
);
it('should fail when starts with a comma #2', () =>
assert.rejects(
async () => await parse([',', '{}']),
/Unexpected token , in JSON at position 0|Unexpected token ',', ",{}" is not valid JSON/
/Unexpected token , in JSON at position 0|Unexpected token ','(, ",{}" is not valid JSON)?$/
)
);
it('should fail when no comma', () =>
assert.rejects(
async () => await parse(['[1 ', ' 2]']),
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 4/
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 4|Expected ']'/
)
);
it('should fail when no comma #2', () =>
assert.rejects(
async () => await parse(['[{}', '{}]']),
/(Unexpected token {|Expected ',' or ']' after array element) in JSON at position 3/
/(Unexpected token {|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/
)
);
});
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('parseChunked()', () => {
yield '[1 ';
yield '2]';
}),
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/
)
);

Expand Down Expand Up @@ -267,7 +267,7 @@ describe('parseChunked()', () => {
yield await Promise.resolve('[1 ');
yield '2]';
}),
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/
)
);

Expand Down Expand Up @@ -346,7 +346,7 @@ describe('parseChunked()', () => {
it('with failure in JSON', () =>
assert.rejects(
() => parseChunked(createReadableNodejsStream(['[1 ', '2]'])),
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3/
/(Unexpected number|Expected ',' or ']' after array element) in JSON at position 3|Expected ']'/
)
);

Expand Down

0 comments on commit 0684c33

Please sign in to comment.