|
1 | | -import { parseString } from './index'; |
| 1 | +import parse from './index'; |
2 | 2 |
|
3 | 3 | describe('dox parser', () => { |
4 | | - it('parse example jsdoc headers', async () => { |
| 4 | + it('parse example jsdoc headers (declaration methods)', async () => { |
5 | 5 | await expect( |
6 | | - parseString( |
7 | | - 'lib/utils/index.js', |
8 | | - `/** |
9 | | - * Finds file in path. |
10 | | - * |
11 | | - * console.log(await findFileInPath('./', 'package.json')); |
12 | | - * console.log(await findFileInPath('../', 'package.json')); |
13 | | - * console.log(await findFileInPath('~/git/github/doxdox/', '.package.json')); |
14 | | - * |
15 | | - * @param {string} [input] Directory to check for file. |
16 | | - * @param {string?} [fileName = 'package.json'] File name to check for. |
17 | | - * @return {Promise<string | null>} Path to package.json file. |
18 | | - * @public |
19 | | - */ |
20 | | -
|
21 | | -const findFileInPath = async (input, fileName = 'package.json') => {}; |
22 | | -
|
23 | | -/** |
24 | | - * Get the root directory of the package, supplied path or URL. |
25 | | - * |
26 | | - * @param {string?} [url] Optional path or URL. |
27 | | - * @return {string} Directory path. |
28 | | - * @public |
29 | | - */ |
30 | | -
|
31 | | -const getRootDirPath = (url) => {};` |
32 | | - ) |
33 | | - ).resolves.toEqual( |
34 | | - expect.objectContaining({ |
35 | | - path: 'lib/utils/index.js', |
36 | | - methods: expect.arrayContaining([ |
37 | | - expect.objectContaining({ |
38 | | - type: 'declaration', |
39 | | - fullName: 'findFileInPath(input, fileName)', |
40 | | - name: 'findFileInPath', |
41 | | - params: expect.arrayContaining([ |
42 | | - expect.objectContaining({ |
43 | | - name: 'input', |
44 | | - types: ['string'] |
45 | | - }), |
46 | | - expect.objectContaining({ |
47 | | - name: 'fileName', |
48 | | - types: ['string'] |
49 | | - }) |
50 | | - ]), |
51 | | - private: false, |
52 | | - returns: expect.arrayContaining([ |
53 | | - expect.objectContaining({ |
54 | | - name: null, |
55 | | - description: 'Path to package.json file.', |
56 | | - types: ['Promise.<string|null>'] |
57 | | - }) |
58 | | - ]), |
59 | | - slug: 'lib-utils-index-js-findfileinpath' |
60 | | - }), |
61 | | - expect.objectContaining({ |
62 | | - type: 'declaration', |
63 | | - fullName: 'getRootDirPath(url)', |
64 | | - name: 'getRootDirPath', |
65 | | - params: expect.arrayContaining([ |
66 | | - expect.objectContaining({ |
67 | | - name: 'url', |
68 | | - types: ['string'] |
69 | | - }) |
70 | | - ]), |
71 | | - private: false, |
72 | | - returns: expect.arrayContaining([ |
73 | | - expect.objectContaining({ |
74 | | - name: null, |
75 | | - description: 'Directory path.', |
76 | | - types: ['string'] |
77 | | - }) |
78 | | - ]), |
79 | | - slug: 'lib-utils-index-js-getrootdirpath' |
80 | | - }) |
81 | | - ]) |
82 | | - }) |
83 | | - ); |
| 6 | + parse(process.cwd(), './test/mocks/declaration.js') |
| 7 | + ).resolves.toMatchSnapshot(); |
84 | 8 | }); |
85 | | - it('parse empty string', async () => { |
86 | | - await expect(parseString('test.js', '')).resolves.toEqual( |
87 | | - expect.objectContaining({ |
88 | | - path: 'test.js', |
89 | | - methods: [] |
90 | | - }) |
91 | | - ); |
| 9 | + it('parse example jsdoc headers (function methods)', async () => { |
| 10 | + await expect( |
| 11 | + parse(process.cwd(), './test/mocks/function.js') |
| 12 | + ).resolves.toMatchSnapshot(); |
| 13 | + }); |
| 14 | + it('parse empty file', async () => { |
| 15 | + await expect( |
| 16 | + parse(process.cwd(), './test/mocks/empty.js') |
| 17 | + ).resolves.toMatchSnapshot(); |
92 | 18 | }); |
93 | 19 | }); |
0 commit comments