-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathfixtures.test.mjs
More file actions
59 lines (53 loc) · 1.77 KB
/
fixtures.test.mjs
File metadata and controls
59 lines (53 loc) · 1.77 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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: {
protocols: ['https'],
protocol: 'https',
port: '',
resource: 'github.com',
host: 'github.com',
user: '',
password: '',
pathname: '/nodejs/node/tree/HEAD',
hash: '',
search: '',
href: 'https://github.com/nodejs/node/tree/HEAD',
query: {},
parse_failed: false,
token: '',
source: 'github.com',
git_suffix: false,
name: 'node',
owner: 'nodejs',
commit: 'HEAD',
ref: 'HEAD',
filepathtype: 'tree',
filepath: '',
organization: 'nodejs',
full_name: 'nodejs/node',
},
});
for (const [k, v] of Object.entries(actualOutput)) {
actualOutput[k] = v.replace(/.*(?=lib\/)/, '');
}
t.assert.snapshot(actualOutput);
});
});
});
});