Skip to content

Commit ed6597c

Browse files
committed
refactor: migrate tests to modern ES modules and node:test framework for improved consistency and maintainability
1 parent 635d352 commit ed6597c

16 files changed

Lines changed: 200 additions & 367 deletions

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
node: [ 18, 20 ]
23+
node: [ 20, latest ]
2424
os:
2525
- ubuntu-latest
2626
- windows-latest

test/.eslintrc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/fixtures/latin13-be.mo

-678 Bytes
Binary file not shown.

test/fixtures/obsolete-be.mo

-125 Bytes
Binary file not shown.

test/fixtures/utf8-be.mo

-851 Bytes
Binary file not shown.

test/mo-compiler-test.js

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,28 @@
11
import { promisify } from 'node:util';
22
import path from 'node:path';
3-
import { mo } from '../src/index.js';
3+
import { mo } from '../lib/index.mjs';
44
import { readFile as fsReadFile } from 'node:fs';
55
import { fileURLToPath } from 'node:url';
6-
import * as chai from 'chai';
6+
import { describe, test } from 'node:test';
7+
import assert from 'node:assert';
78

89
const __filename = fileURLToPath(import.meta.url);
910
const __dirname = path.dirname(__filename);
1011

1112
const readFile = promisify(fsReadFile);
1213

13-
const expect = chai.expect;
14-
15-
const littleEndianMagic = [0xde, 0x12, 0x04, 0x95];
16-
const bigEndianMagic = [0x95, 0x04, 0x12, 0xde];
17-
18-
chai.config.includeStack = true;
19-
2014
describe('MO Compiler', () => {
21-
describe('UTF-8 LE', async () => {
22-
it('should compile', async () => {
15+
describe('UTF-8', () => {
16+
test('should compile', async () => {
2317
const [json, moData] = await Promise.all([
2418
readFile(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf8'),
25-
readFile(path.join(__dirname, 'fixtures/utf8-le.mo'))
19+
readFile(path.join(__dirname, 'fixtures/utf8.mo'))
2620
]);
2721

2822
const compiled = mo.compile(JSON.parse(json));
2923

30-
expect(compiled.toString('utf8')).to.deep.equal(moData.toString('utf8'));
31-
});
32-
33-
it('should have the correct magic number', async () => {
34-
const json = await readFile(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf8');
35-
36-
const compiled = mo.compile(JSON.parse(json));
37-
38-
expect(Array.from(compiled.subarray(0, 4))).to.eql(littleEndianMagic);
39-
});
40-
});
41-
42-
describe('UTF-8 BE', () => {
43-
it('should compile', async () => {
44-
const [json, moData] = await Promise.all([
45-
readFile(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf8'),
46-
readFile(path.join(__dirname, 'fixtures/utf8-be.mo'))
47-
]);
48-
49-
const compiled = mo.compile(JSON.parse(json), { endian: 'be' });
50-
51-
expect(compiled.toString('utf8')).to.deep.equal(moData.toString('utf8'));
52-
});
53-
54-
it('should have the correct magic number', async () => {
55-
const json = await readFile(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf8');
56-
57-
const compiled = mo.compile(JSON.parse(json), { endian: 'be' });
58-
59-
expect(Array.from(compiled.subarray(0, 4))).to.eql(bigEndianMagic);
24+
assert.deepStrictEqual(compiled.toString('utf8'), moData.toString('utf8'));
6025
});
6126
});
6227

63-
describe('Latin-13 LE', () => {
64-
it('should compile', async () => {
65-
const [json, moData] = await Promise.all([
66-
readFile(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf8'),
67-
readFile(path.join(__dirname, 'fixtures/latin13-le.mo'))
68-
]);
69-
70-
const compiled = mo.compile(JSON.parse(json));
71-
72-
expect(compiled.toString('utf8')).to.equal(moData.toString('utf8'));
73-
});
74-
75-
it('should have the correct magic number', async () => {
76-
const json = await readFile(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf8');
77-
78-
const compiled = mo.compile(JSON.parse(json));
79-
80-
expect(Array.from(compiled.subarray(0, 4))).to.eql(littleEndianMagic);
81-
});
82-
});
83-
84-
describe('Latin-13 BE', () => {
85-
it('should compile', async () => {
86-
const [json, moData] = await Promise.all([
87-
readFile(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf8'),
88-
readFile(path.join(__dirname, 'fixtures/latin13-be.mo'))
89-
]);
90-
91-
const compiled = mo.compile(JSON.parse(json), { endian: 'be' });
92-
93-
expect(compiled.toString('utf8')).to.equal(moData.toString('utf8'));
94-
});
95-
96-
it('should have the correct magic number', async () => {
97-
const json = await readFile(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf8');
98-
99-
const compiled = mo.compile(JSON.parse(json), { endian: 'be' });
100-
101-
expect(Array.from(compiled.subarray(0, 4))).to.eql(bigEndianMagic);
102-
});
103-
});
10428
});

0 commit comments

Comments
 (0)