Skip to content

Commit 4072e89

Browse files
cleanup
1 parent f153e98 commit 4072e89

File tree

14 files changed

+216
-205
lines changed

14 files changed

+216
-205
lines changed

src/__tests__/generators.test.mjs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ok, strictEqual } from 'node:assert/strict';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import createGenerator from '../generators.mjs';
@@ -21,8 +21,8 @@ describe('createGenerator', () => {
2121
it('should create a generator orchestrator with runGenerators method', () => {
2222
const { runGenerators } = createGenerator();
2323

24-
ok(runGenerators);
25-
strictEqual(typeof runGenerators, 'function');
24+
assert.ok(runGenerators);
25+
assert.strictEqual(typeof runGenerators, 'function');
2626
});
2727

2828
it('should return the ast input directly when generators list is empty', async () => {
@@ -34,9 +34,9 @@ describe('createGenerator', () => {
3434
});
3535

3636
// Returns array of results, first element is the 'ast' result
37-
ok(Array.isArray(results));
38-
strictEqual(results.length, 1);
39-
ok(results[0]);
37+
assert.ok(Array.isArray(results));
38+
assert.strictEqual(results.length, 1);
39+
assert.ok(results[0]);
4040
});
4141

4242
it('should run metadata generator', async () => {
@@ -48,9 +48,9 @@ describe('createGenerator', () => {
4848
});
4949

5050
// Returns array with one element - the collected metadata array
51-
ok(Array.isArray(results));
52-
strictEqual(results.length, 1);
53-
ok(Array.isArray(results[0]));
51+
assert.ok(Array.isArray(results));
52+
assert.strictEqual(results.length, 1);
53+
assert.ok(Array.isArray(results[0]));
5454
});
5555

5656
it('should handle generator with dependency', async () => {
@@ -63,8 +63,8 @@ describe('createGenerator', () => {
6363
});
6464

6565
// Should complete without error - returns array of results
66-
ok(Array.isArray(results));
67-
strictEqual(results.length, 1);
66+
assert.ok(Array.isArray(results));
67+
assert.strictEqual(results.length, 1);
6868
});
6969

7070
it('should skip already scheduled generators', async () => {
@@ -77,8 +77,8 @@ describe('createGenerator', () => {
7777
});
7878

7979
// Returns array with two elements (same result cached for both)
80-
ok(Array.isArray(results));
81-
strictEqual(results.length, 2);
80+
assert.ok(Array.isArray(results));
81+
assert.strictEqual(results.length, 2);
8282
});
8383

8484
it('should handle multiple generators in sequence', async () => {
@@ -91,8 +91,8 @@ describe('createGenerator', () => {
9191
});
9292

9393
// Returns array of results
94-
ok(Array.isArray(results));
95-
strictEqual(results.length, 1);
94+
assert.ok(Array.isArray(results));
95+
assert.strictEqual(results.length, 1);
9696
});
9797

9898
it('should collect async generator results for dependents', async () => {
@@ -104,8 +104,8 @@ describe('createGenerator', () => {
104104
generators: ['legacy-json'],
105105
});
106106

107-
ok(Array.isArray(results));
108-
strictEqual(results.length, 1);
107+
assert.ok(Array.isArray(results));
108+
assert.strictEqual(results.length, 1);
109109
});
110110

111111
it('should use multiple threads when specified', async () => {
@@ -118,9 +118,9 @@ describe('createGenerator', () => {
118118
});
119119

120120
// Returns array of results
121-
ok(Array.isArray(results));
122-
strictEqual(results.length, 1);
123-
ok(Array.isArray(results[0]));
121+
assert.ok(Array.isArray(results));
122+
assert.strictEqual(results.length, 1);
123+
assert.ok(Array.isArray(results[0]));
124124
});
125125

126126
it('should pass options to generators', async () => {
@@ -135,8 +135,8 @@ describe('createGenerator', () => {
135135
});
136136

137137
// Returns array of results
138-
ok(Array.isArray(results));
139-
strictEqual(results.length, 1);
140-
ok(Array.isArray(results[0]));
138+
assert.ok(Array.isArray(results));
139+
assert.strictEqual(results.length, 1);
140+
assert.ok(Array.isArray(results[0]));
141141
});
142142
});

src/__tests__/metadata.test.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { strictEqual, deepStrictEqual } from 'node:assert/strict';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import GitHubSlugger from 'github-slugger';
@@ -21,7 +21,10 @@ describe('createMetadata', () => {
2121
},
2222
});
2323
metadata.setHeading(heading);
24-
strictEqual(metadata.create(new VFile(), {}).heading.data, heading.data);
24+
assert.strictEqual(
25+
metadata.create(new VFile(), {}).heading.data,
26+
heading.data
27+
);
2528
});
2629

2730
it('should set the stability correctly', () => {
@@ -34,7 +37,7 @@ describe('createMetadata', () => {
3437
};
3538
metadata.addStability(stability);
3639
const actual = metadata.create(new VFile(), {}).stability;
37-
deepStrictEqual(actual, {
40+
assert.deepStrictEqual(actual, {
3841
children: [stability],
3942
type: 'root',
4043
});
@@ -83,7 +86,7 @@ describe('createMetadata', () => {
8386
yaml_position: {},
8487
};
8588
const actual = metadata.create(apiDoc, section);
86-
deepStrictEqual(actual, expected);
89+
assert.deepStrictEqual(actual, expected);
8790
});
8891

8992
it('should be serializable', () => {
@@ -92,6 +95,6 @@ describe('createMetadata', () => {
9295
type: 'root',
9396
children: [],
9497
});
95-
deepStrictEqual(structuredClone(actual), actual);
98+
assert.deepStrictEqual(structuredClone(actual), actual);
9699
});
97100
});

src/__tests__/streaming.test.mjs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deepStrictEqual, ok, strictEqual } from 'node:assert/strict';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import {
@@ -16,7 +16,7 @@ describe('streaming utilities', () => {
1616

1717
const gen = asyncGen();
1818

19-
strictEqual(isAsyncGenerator(gen), true);
19+
assert.strictEqual(isAsyncGenerator(gen), true);
2020
});
2121

2222
it('should return false for regular generators', () => {
@@ -26,24 +26,24 @@ describe('streaming utilities', () => {
2626

2727
const gen = syncGen();
2828

29-
strictEqual(isAsyncGenerator(gen), false);
29+
assert.strictEqual(isAsyncGenerator(gen), false);
3030
});
3131

3232
it('should return false for plain objects', () => {
33-
strictEqual(isAsyncGenerator({}), false);
34-
strictEqual(isAsyncGenerator([]), false);
35-
strictEqual(isAsyncGenerator({ async: true }), false);
33+
assert.strictEqual(isAsyncGenerator({}), false);
34+
assert.strictEqual(isAsyncGenerator([]), false);
35+
assert.strictEqual(isAsyncGenerator({ async: true }), false);
3636
});
3737

3838
it('should return false for null and undefined', () => {
39-
strictEqual(isAsyncGenerator(null), false);
40-
strictEqual(isAsyncGenerator(undefined), false);
39+
assert.strictEqual(isAsyncGenerator(null), false);
40+
assert.strictEqual(isAsyncGenerator(undefined), false);
4141
});
4242

4343
it('should return false for primitives', () => {
44-
strictEqual(isAsyncGenerator(42), false);
45-
strictEqual(isAsyncGenerator('string'), false);
46-
strictEqual(isAsyncGenerator(true), false);
44+
assert.strictEqual(isAsyncGenerator(42), false);
45+
assert.strictEqual(isAsyncGenerator('string'), false);
46+
assert.strictEqual(isAsyncGenerator(true), false);
4747
});
4848

4949
it('should return true for objects with Symbol.asyncIterator', () => {
@@ -55,7 +55,7 @@ describe('streaming utilities', () => {
5555
},
5656
};
5757

58-
strictEqual(isAsyncGenerator(asyncIterable), true);
58+
assert.strictEqual(isAsyncGenerator(asyncIterable), true);
5959
});
6060
});
6161

@@ -69,7 +69,7 @@ describe('streaming utilities', () => {
6969

7070
const result = await collectAsyncGenerator(gen());
7171

72-
deepStrictEqual(result, [1, 2, 3, 4, 5]);
72+
assert.deepStrictEqual(result, [1, 2, 3, 4, 5]);
7373
});
7474

7575
it('should return empty array for empty generator', async () => {
@@ -79,7 +79,7 @@ describe('streaming utilities', () => {
7979

8080
const result = await collectAsyncGenerator(gen());
8181

82-
deepStrictEqual(result, []);
82+
assert.deepStrictEqual(result, []);
8383
});
8484

8585
it('should handle single chunk', async () => {
@@ -89,7 +89,7 @@ describe('streaming utilities', () => {
8989

9090
const result = await collectAsyncGenerator(gen());
9191

92-
deepStrictEqual(result, [1, 2, 3]);
92+
assert.deepStrictEqual(result, [1, 2, 3]);
9393
});
9494

9595
it('should handle empty chunks', async () => {
@@ -102,7 +102,7 @@ describe('streaming utilities', () => {
102102

103103
const result = await collectAsyncGenerator(gen());
104104

105-
deepStrictEqual(result, [1, 2, 3]);
105+
assert.deepStrictEqual(result, [1, 2, 3]);
106106
});
107107

108108
it('should handle objects in chunks', async () => {
@@ -113,16 +113,16 @@ describe('streaming utilities', () => {
113113

114114
const result = await collectAsyncGenerator(gen());
115115

116-
deepStrictEqual(result, [{ a: 1 }, { b: 2 }, { c: 3 }]);
116+
assert.deepStrictEqual(result, [{ a: 1 }, { b: 2 }, { c: 3 }]);
117117
});
118118
});
119119

120120
describe('createStreamingCache', () => {
121121
it('should create a cache with required methods', () => {
122122
const cache = createStreamingCache();
123123

124-
ok(cache);
125-
strictEqual(typeof cache.getOrCollect, 'function');
124+
assert.ok(cache);
125+
assert.strictEqual(typeof cache.getOrCollect, 'function');
126126
});
127127

128128
it('should return same promise for same key', async () => {
@@ -145,8 +145,8 @@ describe('streaming utilities', () => {
145145
const result1 = await promise1;
146146
const result2 = await promise2;
147147

148-
deepStrictEqual(result1, [1, 2, 3]);
149-
strictEqual(result1, result2);
148+
assert.deepStrictEqual(result1, [1, 2, 3]);
149+
assert.strictEqual(result1, result2);
150150
});
151151

152152
it('should return different results for different keys', async () => {
@@ -163,8 +163,8 @@ describe('streaming utilities', () => {
163163
const result1 = await cache.getOrCollect('key1', gen1());
164164
const result2 = await cache.getOrCollect('key2', gen2());
165165

166-
deepStrictEqual(result1, [1, 2]);
167-
deepStrictEqual(result2, [3, 4]);
166+
assert.deepStrictEqual(result1, [1, 2]);
167+
assert.deepStrictEqual(result2, [3, 4]);
168168
});
169169
});
170170
});

src/generators/man-page/utils/__tests__/converter.test.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { strictEqual } from 'node:assert/strict';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import { u } from 'unist-builder';
@@ -20,7 +20,7 @@ const createMockElement = (headingText, description) => ({
2020

2121
const runTests = (cases, conversionFunc) => {
2222
cases.forEach(({ input, expected }) => {
23-
strictEqual(conversionFunc(input), expected);
23+
assert.strictEqual(conversionFunc(input), expected);
2424
});
2525
};
2626

@@ -31,7 +31,7 @@ describe('Mandoc Conversion', () => {
3131
u('heading', { depth: 1 }, [textNode('Main Title')]),
3232
u('paragraph', [textNode('Introductory text.')]),
3333
]);
34-
strictEqual(
34+
assert.strictEqual(
3535
convertNodeToMandoc(node),
3636
'.Sh Main Title\nIntroductory text.'
3737
);
@@ -111,7 +111,7 @@ describe('Mandoc Conversion', () => {
111111
'`-a`, `-b=value`',
112112
'Description of the options.'
113113
);
114-
strictEqual(
114+
assert.strictEqual(
115115
convertOptionToMandoc(mockElement),
116116
`.It Fl a , Fl b Ns = Ns Ar value\nDescription of the options.\n.\n`
117117
);
@@ -122,7 +122,7 @@ describe('Mandoc Conversion', () => {
122122
'`-a`',
123123
'Description of the option without a value.'
124124
);
125-
strictEqual(
125+
assert.strictEqual(
126126
convertOptionToMandoc(mockElement),
127127
`.It Fl a\nDescription of the option without a value.\n.\n`
128128
);
@@ -133,7 +133,7 @@ describe('Mandoc Conversion', () => {
133133
'`-x`, `-y`, `-z=value`',
134134
'Description of multiple options.'
135135
);
136-
strictEqual(
136+
assert.strictEqual(
137137
convertOptionToMandoc(mockElement),
138138
`.It Fl x , Fl y , Fl z Ns = Ns Ar value\nDescription of multiple options.\n.\n`
139139
);
@@ -144,7 +144,7 @@ describe('Mandoc Conversion', () => {
144144
'`-d`, `--option=value with spaces`',
145145
'Description of special options.'
146146
);
147-
strictEqual(
147+
assert.strictEqual(
148148
convertOptionToMandoc(mockElement),
149149
`.It Fl d , Fl -option Ns = Ns Ar value with spaces\nDescription of special options.\n.\n`
150150
);
@@ -157,7 +157,7 @@ describe('Mandoc Conversion', () => {
157157
'`MY_VAR=some_value`',
158158
'Description of the environment variable.'
159159
);
160-
strictEqual(
160+
assert.strictEqual(
161161
convertEnvVarToMandoc(mockElement),
162162
`.It Ev MY_VAR Ar some_value\nDescription of the environment variable.\n.\n`
163163
);
@@ -168,7 +168,7 @@ describe('Mandoc Conversion', () => {
168168
'`MY_VAR=`',
169169
'Description of the environment variable without a value.'
170170
);
171-
strictEqual(
171+
assert.strictEqual(
172172
convertEnvVarToMandoc(mockElement),
173173
`.It Ev MY_VAR\nDescription of the environment variable without a value.\n.\n`
174174
);
@@ -179,7 +179,7 @@ describe('Mandoc Conversion', () => {
179179
'`SPECIAL_VAR=special value!`',
180180
'Description of special environment variable.'
181181
);
182-
strictEqual(
182+
assert.strictEqual(
183183
convertEnvVarToMandoc(mockElement),
184184
`.It Ev SPECIAL_VAR Ar special value!\nDescription of special environment variable.\n.\n`
185185
);

src/generators/metadata/__tests__/index.test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deepStrictEqual, strictEqual } from 'node:assert/strict';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import generator from '../index.mjs';
@@ -24,8 +24,8 @@ describe('generators/metadata/index', () => {
2424
results.push(chunk);
2525
}
2626

27-
strictEqual(results.length, 2);
28-
deepStrictEqual(results[0], [1, 2, 3]);
29-
deepStrictEqual(results[1], [4]);
27+
assert.strictEqual(results.length, 2);
28+
assert.deepStrictEqual(results[0], [1, 2, 3]);
29+
assert.deepStrictEqual(results[1], [4]);
3030
});
3131
});

0 commit comments

Comments
 (0)