mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.2 KiB
79 lines
2.2 KiB
9 years ago
|
'use strict';
|
||
|
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const fs = require('fs');
|
||
|
|
||
|
const json = require('../../tools/doc/json.js');
|
||
|
|
||
|
// Outputs valid json with the expected fields when given simple markdown
|
||
|
// Test data is a list of objects with two properties.
|
||
|
// The file property is the file path.
|
||
|
// The json property is some json which will be generated by the doctool.
|
||
|
var testData = [
|
||
|
{
|
||
|
'file': common.fixturesDir + '/sample_document.md',
|
||
|
'json': {
|
||
|
'source': 'foo',
|
||
|
'modules': [ { 'textRaw': 'Sample Markdown',
|
||
|
'name': 'sample_markdown',
|
||
|
'modules': [ { 'textRaw':'Seussian Rhymes',
|
||
|
'name': 'seussian_rhymes',
|
||
|
'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' +
|
||
|
'<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n',
|
||
|
'type': 'module',
|
||
|
'displayName': 'Seussian Rhymes'
|
||
|
} ],
|
||
|
'type': 'module',
|
||
|
'displayName': 'Sample Markdown'
|
||
|
} ]
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
'file': common.fixturesDir + '/order_of_end_tags_5873.md',
|
||
|
'json': {
|
||
|
'source':'foo',
|
||
|
'modules': [ {
|
||
|
'textRaw': 'Title',
|
||
|
'name': 'title',
|
||
|
'modules': [ {
|
||
|
'textRaw': 'Subsection',
|
||
|
'name': 'subsection',
|
||
|
'classMethods': [ {
|
||
|
'textRaw': 'Class Method: Buffer.from(array)',
|
||
|
'type':'classMethod',
|
||
|
'name':'from',
|
||
|
'signatures': [ {
|
||
|
'params': [ {
|
||
|
'textRaw': '`array` {Array} ',
|
||
|
'name': 'array',
|
||
|
'type': 'Array'
|
||
|
} ]
|
||
|
},
|
||
|
{
|
||
|
'params' : [ {
|
||
|
'name': 'array'
|
||
|
} ]
|
||
|
}
|
||
|
]
|
||
|
} ],
|
||
|
'type': 'module',
|
||
|
'displayName': 'Subsection'
|
||
|
} ],
|
||
|
'type': 'module',
|
||
|
'displayName': 'Title'
|
||
|
} ]
|
||
|
}
|
||
|
}
|
||
|
];
|
||
|
|
||
|
testData.forEach(function(item) {
|
||
|
fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) {
|
||
|
assert.ifError(err);
|
||
|
json(input, 'foo', common.mustCall(function(err, output) {
|
||
|
assert.ifError(err);
|
||
|
assert.deepStrictEqual(output, item.json);
|
||
|
}));
|
||
|
}));
|
||
|
});
|