-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathfixtures.test.mjs
More file actions
34 lines (28 loc) · 1.08 KB
/
fixtures.test.mjs
File metadata and controls
34 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { describe, it } from 'node:test';
import { readdir } from 'node:fs/promises';
import { basename, extname, join } from 'node:path';
import astJs from '../../ast-js/index.mjs';
import apiLinks from '../index.mjs';
const FIXTURES_DIRECTORY = join(import.meta.dirname, 'fixtures');
const fixtures = await readdir(FIXTURES_DIRECTORY);
const sourceFiles = fixtures
.filter(fixture => extname(fixture) === '.js')
.map(fixture => join(FIXTURES_DIRECTORY, fixture));
describe('api links', () => {
describe('should work correctly for all fixtures', () => {
sourceFiles.forEach(sourceFile => {
it(`${basename(sourceFile)}`, async t => {
const astJsResult = await astJs.generate(undefined, {
input: [sourceFile],
});
const actualOutput = await apiLinks.generate(astJsResult, {
gitRef: 'https://github.com/nodejs/node/tree/HEAD',
});
for (const [k, v] of Object.entries(actualOutput)) {
actualOutput[k] = v.replace(/.*(?=lib\/)/, '');
}
t.assert.snapshot(actualOutput);
});
});
});
});