2021-02-05 14:24:41 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
import { generate_rules_description } from '../description';
|
|
|
|
import { withTestDir, createFiles } from '../testutils';
|
|
|
|
|
|
|
|
describe('description generation', () => {
|
|
|
|
test('generates html from asciidoc', () => {
|
|
|
|
return withTestDir((srcPath) => {
|
|
|
|
createFiles(srcPath, {
|
|
|
|
'S100/description.adoc': 'Generic content',
|
|
|
|
'S100/java/rule.adoc':
|
|
|
|
['include::../description.adoc[]',
|
|
|
|
'Specific content'].join('\n')
|
|
|
|
});
|
|
|
|
return withTestDir(async (dstPath) => {
|
|
|
|
generate_rules_description(srcPath, dstPath);
|
|
|
|
|
|
|
|
const ruleHtml = fs.readFileSync(path.join(dstPath, 'S100', 'java-description.html'));
|
|
|
|
expect(ruleHtml.toString()).toEqual(
|
2022-01-14 17:06:36 +01:00
|
|
|
[
|
|
|
|
'<div class="sect1">',
|
|
|
|
'<h2 id="_description">Description</h2>',
|
|
|
|
'<div class="sectionbody">',
|
|
|
|
'<div class="paragraph">',
|
|
|
|
'<p>Generic content',
|
|
|
|
'Specific content</p>',
|
|
|
|
'</div>',
|
|
|
|
'</div>',
|
|
|
|
'</div>'
|
|
|
|
].join('\n')
|
2021-02-05 14:24:41 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|