Skip to content

Commit 2268a2a

Browse files
committed
replace chai with node:assert
1 parent 0da43ae commit 2268a2a

8 files changed

Lines changed: 113 additions & 109 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"devDependencies": {
3535
"@eslint/js": "^9.39.2",
3636
"@stylistic/eslint-plugin": "^5.6.1",
37-
"chai": "^6.2.2",
3837
"eslint": "^9.39.2",
3938
"globals": "^16.5.0"
4039
},

test/mo-compiler-test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from 'node:test';
2-
import * as chai from 'chai';
2+
import assert from 'node:assert';
33
import { promisify } from 'util';
44
import path from 'path';
55
import { mo } from '../index.js';
@@ -11,9 +11,6 @@ const __dirname = path.dirname(__filename);
1111

1212
const readFile = promisify(fsReadFile);
1313

14-
const expect = chai.expect;
15-
chai.config.includeStack = true;
16-
1714
describe('MO Compiler', () => {
1815
describe('UTF-8', () => {
1916
it('should compile', async () => {
@@ -24,7 +21,7 @@ describe('MO Compiler', () => {
2421

2522
const compiled = mo.compile(JSON.parse(json));
2623

27-
expect(compiled.toString('utf8')).to.deep.equal(moData.toString('utf8'));
24+
assert.deepStrictEqual(compiled.toString('utf8'), moData.toString('utf8'));
2825
});
2926
});
3027

@@ -37,7 +34,7 @@ describe('MO Compiler', () => {
3734

3835
const compiled = mo.compile(JSON.parse(json));
3936

40-
expect(compiled.toString('utf8')).to.equal(moData.toString('utf8'));
37+
assert.strictEqual(compiled.toString('utf8'), moData.toString('utf8'));
4138
});
4239
});
4340
});

test/mo-parser-test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from 'node:test';
2-
import * as chai from 'chai';
2+
import assert from 'node:assert';
33
import { promisify } from 'util';
44
import path from 'path';
55
import { mo } from '../index.js';
@@ -11,9 +11,6 @@ const __dirname = path.dirname(__filename);
1111

1212
const readFile = promisify(fsReadFile);
1313

14-
const expect = chai.expect;
15-
chai.config.includeStack = true;
16-
1714
describe('MO Parser', () => {
1815
describe('UTF-8', () => {
1916
it('should parse', async () => {
@@ -24,7 +21,7 @@ describe('MO Parser', () => {
2421

2522
const parsed = mo.parse(moData);
2623

27-
expect(parsed).to.deep.equal(JSON.parse(json));
24+
assert.deepStrictEqual(parsed, JSON.parse(json));
2825
});
2926
});
3027

@@ -37,7 +34,7 @@ describe('MO Parser', () => {
3734

3835
const parsed = mo.parse(moData);
3936

40-
expect(parsed).to.deep.equal(JSON.parse(json));
37+
assert.deepStrictEqual(parsed, JSON.parse(json));
4138
});
4239
});
4340
});

test/module.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { describe, it } from 'node:test';
2-
import { expect } from 'chai';
2+
import assert from 'node:assert';
33
import { po, mo } from '../index.js';
44

55
describe('esm module', () => {
66
it('should allow named imports', () => {
7-
expect(po.parse).to.be.a('function');
8-
expect(po.compile).to.be.a('function');
9-
expect(mo.parse).to.be.a('function');
10-
expect(mo.compile).to.be.a('function');
7+
assert.strictEqual(typeof po.parse, 'function');
8+
assert.strictEqual(typeof po.compile, 'function');
9+
assert.strictEqual(typeof mo.parse, 'function');
10+
assert.strictEqual(typeof mo.compile, 'function');
1111
});
1212
});

test/po-compiler-test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { promisify } from 'util';
33
import path from 'path';
44
import { readFile as fsReadFile } from 'fs';
55
import { describe, it } from 'node:test';
6-
import * as chai from 'chai';
6+
import assert from 'node:assert';
77
import { po } from '../index.js';
88
import { fileURLToPath } from 'url';
99

@@ -12,9 +12,6 @@ const __dirname = path.dirname(__filename);
1212

1313
const readFile = promisify(fsReadFile);
1414

15-
const expect = chai.expect;
16-
chai.config.includeStack = true;
17-
1815
describe('PO Compiler', () => {
1916
describe('Headers', () => {
2017
it('should keep tile casing', async () => {
@@ -26,7 +23,7 @@ describe('PO Compiler', () => {
2623
const compiled = po.compile(JSON.parse(json), { eol: EOL })
2724
.toString('utf8');
2825

29-
expect(compiled).to.equal(poData);
26+
assert.strictEqual(compiled, poData);
3027
});
3128
});
3229

@@ -40,7 +37,7 @@ describe('PO Compiler', () => {
4037
const compiled = po.compile(JSON.parse(json), { eol: EOL })
4138
.toString('utf8');
4239

43-
expect(compiled).to.equal(poData);
40+
assert.strictEqual(compiled, poData);
4441
});
4542
});
4643

@@ -55,7 +52,7 @@ describe('PO Compiler', () => {
5552
const compiled = po.compile(JSON.parse(json), { eol: EOL })
5653
.toString('latin1');
5754

58-
expect(compiled).to.equal(poData);
55+
assert.strictEqual(compiled, poData);
5956
});
6057
});
6158

@@ -69,7 +66,7 @@ describe('PO Compiler', () => {
6966
const compiled = po.compile(JSON.parse(json), { eol: EOL })
7067
.toString('utf8');
7168

72-
expect(compiled).to.equal(pot);
69+
assert.strictEqual(compiled, pot);
7370
});
7471
});
7572

@@ -83,7 +80,7 @@ describe('PO Compiler', () => {
8380
const compiled = po.compile(JSON.parse(json), { foldLength: 0, eol: EOL })
8481
.toString('utf8');
8582

86-
expect(compiled).to.equal(poData);
83+
assert.strictEqual(compiled, poData);
8784
});
8885

8986
it('should compile with different folding', async () => {
@@ -95,7 +92,7 @@ describe('PO Compiler', () => {
9592
const compiled = po.compile(JSON.parse(json), { foldLength: 100, eol: EOL })
9693
.toString('utf8');
9794

98-
expect(compiled).to.equal(poData);
95+
assert.strictEqual(compiled, poData);
9996
});
10097
});
10198

@@ -109,7 +106,7 @@ describe('PO Compiler', () => {
109106
const compiled = po.compile(JSON.parse(json), { sort: true, eol: EOL })
110107
.toString('utf8');
111108

112-
expect(compiled).to.equal(pot);
109+
assert.strictEqual(compiled, pot);
113110
});
114111

115112
it('should sort entries using a custom `sort` function', async () => {
@@ -144,9 +141,9 @@ describe('PO Compiler', () => {
144141
const compiled2 = po.compile(JSON.parse(json2), { sort: compareMsgidAndMsgctxt, eol: EOL })
145142
.toString('utf8');
146143

147-
expect(compiled1).to.equal(compiled2);
148-
expect(compiled1).to.equal(pot);
149-
expect(compiled2).to.equal(pot);
144+
assert.strictEqual(compiled1, compiled2);
145+
assert.strictEqual(compiled1, pot);
146+
assert.strictEqual(compiled2, pot);
150147
});
151148
});
152149

@@ -160,7 +157,7 @@ describe('PO Compiler', () => {
160157
const compiled = po.compile(JSON.parse(json), { escapeCharacters: false, foldLength: 0, eol: EOL })
161158
.toString('utf8');
162159

163-
expect(compiled).to.equal(poData);
160+
assert.strictEqual(compiled, poData);
164161
});
165162
});
166163
});

test/po-obsolete-test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EOL } from 'os';
22
import { describe, it } from 'node:test';
3-
import * as chai from 'chai';
3+
import assert from 'node:assert';
44
import { promisify } from 'util';
55
import path from 'path';
66
import fs from 'fs';
@@ -12,9 +12,6 @@ const __dirname = path.dirname(__filename);
1212

1313
const readFile = promisify(fs.readFile);
1414

15-
const expect = chai.expect;
16-
chai.config.includeStack = true;
17-
1815
describe('Obsolete', async () => {
1916
const [po, mo, jsonString] = await Promise.all([
2017
readFile(path.join(__dirname, 'fixtures/obsolete.po')),
@@ -30,21 +27,21 @@ describe('Obsolete', async () => {
3027
it('should parse obsolete messages', async () => {
3128
const parsed = gettextParser.po.parse(po);
3229

33-
expect(parsed).to.deep.equal(json);
30+
assert.deepStrictEqual(parsed, json);
3431
});
3532
});
3633
describe('PO Compiler', () => {
3734
it('should compile obsolete messages', async () => {
3835
const compiled = gettextParser.po.compile(json, { eol: EOL }).toString('utf8');
3936

40-
expect(compiled).to.be.equal(poString);
37+
assert.strictEqual(compiled, poString);
4138
});
4239
});
4340
describe('MO Compiler', () => {
4441
it('should ignore obsolete messages', async () => {
4542
const compiled = gettextParser.mo.compile(json).toString('utf8');
4643

47-
expect(compiled).to.be.equal(moString);
44+
assert.strictEqual(compiled, moString);
4845
});
4946
});
5047
});

0 commit comments

Comments
 (0)