|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +constcommon=require('../common'); |
| 4 | +constassert=require('assert'); |
| 5 | +constfs=require('fs'); |
| 6 | + |
| 7 | +constjson=require('../../tools/doc/json.js'); |
| 8 | + |
| 9 | +// Outputs valid json with the expected fields when given simple markdown |
| 10 | +// Test data is a list of objects with two properties. |
| 11 | +// The file property is the file path. |
| 12 | +// The json property is some json which will be generated by the doctool. |
| 13 | +vartestData=[ |
| 14 | +{ |
| 15 | +'file': common.fixturesDir+'/sample_document.md', |
| 16 | +'json': { |
| 17 | +'source': 'foo', |
| 18 | +'modules': [{'textRaw': 'Sample Markdown', |
| 19 | +'name': 'sample_markdown', |
| 20 | +'modules': [{'textRaw':'Seussian Rhymes', |
| 21 | +'name': 'seussian_rhymes', |
| 22 | +'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>'+ |
| 23 | +'<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n', |
| 24 | +'type': 'module', |
| 25 | +'displayName': 'Seussian Rhymes' |
| 26 | +}], |
| 27 | +'type': 'module', |
| 28 | +'displayName': 'Sample Markdown' |
| 29 | +}] |
| 30 | +} |
| 31 | +}, |
| 32 | +{ |
| 33 | +'file': common.fixturesDir+'/order_of_end_tags_5873.md', |
| 34 | +'json': { |
| 35 | +'source':'foo', |
| 36 | +'modules': [{ |
| 37 | +'textRaw': 'Title', |
| 38 | +'name': 'title', |
| 39 | +'modules': [{ |
| 40 | +'textRaw': 'Subsection', |
| 41 | +'name': 'subsection', |
| 42 | +'classMethods': [{ |
| 43 | +'textRaw': 'Class Method: Buffer.from(array)', |
| 44 | +'type':'classMethod', |
| 45 | +'name':'from', |
| 46 | +'signatures': [{ |
| 47 | +'params': [{ |
| 48 | +'textRaw': '`array`{Array} ', |
| 49 | +'name': 'array', |
| 50 | +'type': 'Array' |
| 51 | +}] |
| 52 | +}, |
| 53 | +{ |
| 54 | +'params' : [{ |
| 55 | +'name': 'array' |
| 56 | +}] |
| 57 | +} |
| 58 | +] |
| 59 | +}], |
| 60 | +'type': 'module', |
| 61 | +'displayName': 'Subsection' |
| 62 | +}], |
| 63 | +'type': 'module', |
| 64 | +'displayName': 'Title' |
| 65 | +}] |
| 66 | +} |
| 67 | +} |
| 68 | +]; |
| 69 | + |
| 70 | +testData.forEach(function(item){ |
| 71 | +fs.readFile(item.file,'utf8',common.mustCall(function(err,input){ |
| 72 | +assert.ifError(err); |
| 73 | +json(input,'foo',common.mustCall(function(err,output){ |
| 74 | +assert.ifError(err); |
| 75 | +assert.deepStrictEqual(output,item.json); |
| 76 | +})); |
| 77 | +})); |
| 78 | +}); |
0 commit comments