Skip to content

Commit

Permalink
Merge pull request #78 from slowli/dependabot/npm_and_yarn/chai-5.0.0
Browse files Browse the repository at this point in the history
Update `chai` peer dependency to 5.0.3
  • Loading branch information
slowli authored Jan 28, 2024
2 parents 2fd24a0 + 8b8713d commit ea66079
Show file tree
Hide file tree
Showing 15 changed files with 5,618 additions and 5,027 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm ci && (cd e2e-tests; npm ci)
- run: npm run lint
- run: npm test
env:
CI: true
- run: npm run test-ts
- run: npm run test-browser
- run: npm run test:browser -- --coverage
- name: Run end-to-end tests
run: (cd e2e-tests; npm test)
- name: Coveralls
uses: coverallsapp/github-action@master
if: success() && startsWith(matrix.node-version, '18')
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/node_modules
node_modules
npm-debug.log
# Auto-generated by TypeScript
/test/types.js
types.js
# Coverage reports
/coverage
# IDE
Expand Down
22 changes: 22 additions & 0 deletions e2e-tests/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Tests with `chai` v4 and CommonJS import.
*/
const chai = require('chai');
const { expect, assert } = chai.use(require('chai-bytes'));

const buffer = Uint8Array.from([1, 2, 3]);

// Check `expect` behavior.
expect(buffer).to.equalBytes([1, 2, 3]);
expect(buffer).to.equalBytes('010203');
expect(buffer).to.equalBytes(Uint8Array.from([1, 2, 3]));
// Check chaining
expect(buffer).to.not.equalBytes('0102');
buffer[2] += 1;
expect(buffer).to.have.lengthOf(3).and.equalBytes([1, 2, 4]);

// Check `assert` behavior.
buffer[2] -= 1;
assert.equalBytes(buffer, [1, 2, 3], 'some message');
assert.equalBytes(buffer, '010203');
assert.equalBytes(buffer, Uint8Array.from([1, 2, 3]));
23 changes: 23 additions & 0 deletions e2e-tests/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Tests with `chai` v5 and ES module import.
*/
import * as chai from 'chai5';
import chaiBytes from 'chai-bytes';

const { expect, assert } = chai.use(chaiBytes);
const buffer = Uint8Array.from([1, 2, 3]);

// Check `expect` behavior.
expect(buffer).to.equalBytes([1, 2, 3]);
expect(buffer).to.equalBytes('010203');
expect(buffer).to.equalBytes(Uint8Array.from([1, 2, 3]));
// Check chaining
expect(buffer).to.not.equalBytes('0102');
buffer[2] += 1;
expect(buffer).to.have.lengthOf(3).and.equalBytes([1, 2, 4]);

// Check `assert` behavior.
buffer[2] -= 1;
assert.equalBytes(buffer, [1, 2, 3], 'some message');
assert.equalBytes(buffer, '010203');
assert.equalBytes(buffer, Uint8Array.from([1, 2, 3]));
Loading

0 comments on commit ea66079

Please sign in to comment.