2021-02-05 14:24:41 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
|
2022-01-17 20:13:15 +01:00
|
|
|
import { generateRulesDescription } from '../description';
|
2021-02-05 14:24:41 +01:00
|
|
|
import { withTestDir, createFiles } from '../testutils';
|
|
|
|
|
|
|
|
describe('description generation', () => {
|
2022-01-28 09:51:13 +01:00
|
|
|
test('generates html from asciidoc', () => {
|
2021-02-05 14:24:41 +01:00
|
|
|
return withTestDir((srcPath) => {
|
|
|
|
createFiles(srcPath, {
|
2022-01-28 09:51:13 +01:00
|
|
|
'S100/rule.adoc': 'Generic content',
|
|
|
|
'S100/java/rule.adoc': [
|
|
|
|
'include::../rule.adoc[]',
|
|
|
|
'Specific content',
|
|
|
|
].join('\n'),
|
|
|
|
|
|
|
|
'S501/rule.adoc': 'Generic content, no active language',
|
2021-02-05 14:24:41 +01:00
|
|
|
});
|
2022-01-28 09:51:13 +01:00
|
|
|
|
2021-02-05 14:24:41 +01:00
|
|
|
return withTestDir(async (dstPath) => {
|
2022-01-17 20:13:15 +01:00
|
|
|
generateRulesDescription(srcPath, dstPath);
|
2021-02-05 14:24:41 +01:00
|
|
|
|
2022-01-28 09:51:13 +01:00
|
|
|
const s100Java = path.join(dstPath, 'S100', 'java-description.html');
|
|
|
|
expect(fs.existsSync(s100Java)).toBeTruthy();
|
|
|
|
const htmlS100Java = fs.readFileSync(s100Java);
|
|
|
|
expect(htmlS100Java.toString()).toEqual([
|
|
|
|
'<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'));
|
|
|
|
|
|
|
|
const s501Default = path.join(dstPath, 'S501', 'default-description.html');
|
|
|
|
expect(fs.existsSync(s501Default)).toBeTruthy();
|
|
|
|
const htmlS501Default = fs.readFileSync(s501Default);
|
|
|
|
expect(htmlS501Default.toString()).toEqual([
|
|
|
|
'<div class="sect1">',
|
|
|
|
'<h2 id="_description">Description</h2>',
|
|
|
|
'<div class="sectionbody">',
|
|
|
|
'<div class="paragraph">',
|
|
|
|
'<p>Generic content, no active language</p>',
|
|
|
|
'</div>',
|
|
|
|
'</div>',
|
|
|
|
'</div>',
|
|
|
|
].join('\n'));
|
2021-02-05 14:24:41 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|