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