import fs from 'fs'; import path from 'path'; import { generateOneRuleDescription, generateRulesDescription } from '../description'; import { withTestDir, createFiles } from '../testutils'; describe('description generation', () => { test('generates html from asciidoc', () => { return withTestDir((srcPath) => { createFiles(srcPath, { 'S100/rule.adoc': 'Generic content', 'S100/java/rule.adoc': ` include::../rule.adoc[] Specific content == Test various forms of auto-link for RSPEC. S100 * See S100, S101,S102. * See RSPEC-101 * But not S103badref. * This is a code literal \`+S234+\` but this isn't S567. \\https://sonarsource.github.io/rspec/#/rspec/S100 https://sonarsource.github.io/rspec/#/rspec/S100/cfamily https://sonarsource.github.io/rspec/#/rspec/S100/cfamily[] [source,cpp] ---- int foo() { // No auto-links in code! auto S100 = 100; auto U100 = 100u; return S100 + U100; } ---- After snippet, See S100. [source,cpp] ---- int goo() { // No auto-links in code! // S100 } ---- more ref: RSPEC-200. `, 'S101/rule.adoc': 'Generic content', 'S101/java/rule.adoc': ` include::../rule.adoc[] Specific content See S100. `, 'S501/rule.adoc': 'Generic content, no active language', }); return withTestDir(async (dstPath) => { generateRulesDescription(srcPath, dstPath); const s100Java = path.join(dstPath, 'S100', 'java-description.html'); expect(fs.existsSync(s100Java)).toBeTruthy(); const htmlS100Java = fs.readFileSync(s100Java); expect(htmlS100Java.toString()).toMatchInlineSnapshot(` "
Generic content Specific content
Generic content Specific content See S100.
Generic content, no active language