forked from typedoc2md/typedoc-plugin-markdown
/
plugin.spec.ts
57 lines (51 loc) · 1.52 KB
/
plugin.spec.ts
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
import * as fs from 'fs-extra';
import * as tmp from 'tmp';
import typedocPlugin from '../../dist/plugin';
tmp.setGracefulCleanup();
async function bootstrap(tmpobj: tmp.DirResult, customOptions = {}) {
const options = {
id: 'default',
// logger: 'none',
entryPoints: ['../../stub-project/src/theme.ts'],
tsconfig: '../../stub-project/tsconfig.json',
} as any;
const plugin = typedocPlugin(
{
siteDir: tmpobj.name,
generatedFilesDir: '',
siteConfig: {},
} as any,
{
...options,
...customOptions,
},
);
return await plugin.loadContent();
}
describe(`Plugin:`, () => {
describe(`(docs)`, () => {
let tmpobj;
beforeAll(async () => {
tmpobj = tmp.dirSync();
await bootstrap(tmpobj, { sidebar: { collapsed: false } });
});
test(`should render`, () => {
const files = fs.readdirSync(tmpobj.name + '/docs/api');
expect(files.sort((a, b) => a.localeCompare(b))).toMatchSnapshot();
});
test(`should write doc`, () => {
const sidebar = fs.readFileSync(tmpobj.name + '/docs/api/index.md');
expect(sidebar.toString()).toMatchSnapshot();
});
test(`should write category yaml`, () => {
const sidebar = fs.readFileSync(
tmpobj.name + '/docs/api/classes/_category_.yml',
);
expect(sidebar.toString()).toMatchSnapshot();
const parentSidebar = fs.readFileSync(
tmpobj.name + '/docs/api/_category_.yml',
);
expect(parentSidebar.toString()).toMatchSnapshot();
});
});
});