Skip to content

Commit

Permalink
Merge pull request #67 from badgateway/ditch-chai
Browse files Browse the repository at this point in the history
Replace chai with `node:assert`
  • Loading branch information
evert authored Oct 2, 2024
2 parents 1b182f5 + 8ed8e35 commit acac73a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 98 deletions.
86 changes: 0 additions & 86 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
],
"homepage": "https://github.com/evert/structured-header#readme",
"devDependencies": {
"@types/chai": "^5.0.0",
"@types/node": "^18.19.10",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"base32-decode": "^1.0.0",
"base32-encode": "^2.0.0",
"chai": "^5.0.3",
"eslint": "^9.11.1",
"typescript": "^5.1.3"
},
Expand Down
14 changes: 7 additions & 7 deletions test/httpwg-tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { describe, it } from 'node:test';
import {
parseItem,
Expand All @@ -21,6 +20,7 @@ import base32Decode from 'base32-decode';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import assert from 'node:assert';

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

Expand Down Expand Up @@ -139,7 +139,7 @@ function makeParseTest(test) {
}

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

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

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

try {
expect(result).to.deep.equal(expected);
assert.deepStrictEqual(result, expected);
} catch (e) {
if (test.can_fail) {
// Optional failure
Expand Down Expand Up @@ -248,23 +248,23 @@ function makeSerializeTest(test) {
}

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

if (hadError) {
// There was an error
if (test.can_fail) {

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

try {
expect(output).to.deep.equal(expected);
assert.strictEqual(output, expected);
} catch (e) {

if (test.can_fail) {
Expand Down
7 changes: 4 additions & 3 deletions test/serializer-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
serializeItem,
SerializeError
} from '../dist/index.js';
import { expect} from 'chai';
import { describe, it } from 'node:test';
import assert from 'node:assert';

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

const str = serializeDictionary(simpleDict);
expect(str).to.equal(
assert.equal(
str,
'a=1, b, c="d", f=(1 2 3);a="b"'
);

Expand All @@ -45,7 +46,7 @@ describe('serializer shorthands', () => {
throw err;
}
}
expect(caught).to.be.true;
assert.ok(caught);

});

Expand Down

0 comments on commit acac73a

Please sign in to comment.