Skip to content

Commit acac73a

Browse files
authored
Merge pull request #67 from badgateway/ditch-chai
Replace chai with `node:assert`
2 parents 1b182f5 + 8ed8e35 commit acac73a

File tree

4 files changed

+11
-98
lines changed

4 files changed

+11
-98
lines changed

package-lock.json

Lines changed: 0 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@
3535
],
3636
"homepage": "https://github.com/evert/structured-header#readme",
3737
"devDependencies": {
38-
"@types/chai": "^5.0.0",
3938
"@types/node": "^18.19.10",
4039
"@typescript-eslint/eslint-plugin": "^8.8.0",
4140
"@typescript-eslint/parser": "^8.8.0",
4241
"base32-decode": "^1.0.0",
4342
"base32-encode": "^2.0.0",
44-
"chai": "^5.0.3",
4543
"eslint": "^9.11.1",
4644
"typescript": "^5.1.3"
4745
},

test/httpwg-tests.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { expect } from 'chai';
21
import { describe, it } from 'node:test';
32
import {
43
parseItem,
@@ -21,6 +20,7 @@ import base32Decode from 'base32-decode';
2120
import fs from 'node:fs';
2221
import path from 'node:path';
2322
import { fileURLToPath } from 'node:url';
23+
import assert from 'node:assert';
2424

2525
describe('HTTP-WG tests', () => {
2626

@@ -139,7 +139,7 @@ function makeParseTest(test) {
139139
}
140140

141141
if (test.must_fail) {
142-
expect(hadError).to.equal(true, 'Parsing this should result in a failure');
142+
assert.ok(hadError, 'Parsing this should result in a failure');
143143

144144
if (!(caughtError instanceof ParseError)) {
145145
console.error('Original error:');
@@ -154,7 +154,7 @@ function makeParseTest(test) {
154154
if (hadError) {
155155

156156
if (test.can_fail) {
157-
expect(caughtError instanceof ParseError).to.equal(true);
157+
assert.ok(caughtError instanceof ParseError);
158158
} else {
159159
// Failure is NOT OK
160160
throw new Error('We should not have failed but got an error: ' + caughtError.message);
@@ -164,7 +164,7 @@ function makeParseTest(test) {
164164
result = packTestValue(result);
165165

166166
try {
167-
expect(result).to.deep.equal(expected);
167+
assert.deepStrictEqual(result, expected);
168168
} catch (e) {
169169
if (test.can_fail) {
170170
// Optional failure
@@ -248,23 +248,23 @@ function makeSerializeTest(test) {
248248
}
249249

250250
if (test.must_fail) {
251-
expect(hadError).to.equal(true, 'Parsing this should result in a failure');
251+
assert.ok(hadError, 'Parsing this should result in a failure');
252252
} else {
253253

254254
if (hadError) {
255255
// There was an error
256256
if (test.can_fail) {
257257

258258
// Failure is OK
259-
expect(hadError).to.equal(true);
259+
assert.ok(hadError);
260260
} else {
261261
// Failure is NOT OK
262262
throw new Error('We should not have failed but got an error: ' + caughtError.message);
263263
}
264264
}
265265

266266
try {
267-
expect(output).to.deep.equal(expected);
267+
assert.strictEqual(output, expected);
268268
} catch (e) {
269269

270270
if (test.can_fail) {

test/serializer-tests.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
serializeItem,
44
SerializeError
55
} from '../dist/index.js';
6-
import { expect} from 'chai';
76
import { describe, it } from 'node:test';
7+
import assert from 'node:assert';
88

99
/**
1010
* These tests cover cases that aren't covered by the HTTPWG tests.
@@ -23,7 +23,8 @@ describe('serializer shorthands', () => {
2323
};
2424

2525
const str = serializeDictionary(simpleDict);
26-
expect(str).to.equal(
26+
assert.equal(
27+
str,
2728
'a=1, b, c="d", f=(1 2 3);a="b"'
2829
);
2930

@@ -45,7 +46,7 @@ describe('serializer shorthands', () => {
4546
throw err;
4647
}
4748
}
48-
expect(caught).to.be.true;
49+
assert.ok(caught);
4950

5051
});
5152

0 commit comments

Comments
 (0)