/* eslint-disable no-useless-escape */ import templater from '~/static_site_editor/services/templater'; describe('templater', () => { const source = `Below this line is a simple ERB (single-line erb block) example. <% some erb code %> Below this line is a complex ERB (multi-line erb block) example. <% if apptype.maturity && (apptype.maturity != "planned") %> <% maturity = "This application type is at the \"#{apptype.maturity}\" level of maturity." %> <% end %> Below this line is a non-erb (single-line HTML) markup example that also has erb. <%= compensation_roadmap.role_path %> Below this line is a non-erb (multi-line HTML block) markup example that also has erb. Below this line is a block of HTML.

Heading

Some paragraph...

Below this line is a codeblock of the same HTML that should be ignored and preserved. \`\`\` html

Heading

Some paragraph...

\`\`\` `; const sourceTemplated = `Below this line is a simple ERB (single-line erb block) example. \`\`\` sse <% some erb code %> \`\`\` Below this line is a complex ERB (multi-line erb block) example. \`\`\` sse <% if apptype.maturity && (apptype.maturity != "planned") %> <% maturity = "This application type is at the \"#{apptype.maturity}\" level of maturity." %> <% end %> \`\`\` Below this line is a non-erb (single-line HTML) markup example that also has erb. \`\`\` sse <%= compensation_roadmap.role_path %> \`\`\` Below this line is a non-erb (multi-line HTML block) markup example that also has erb. \`\`\` sse \`\`\` Below this line is a block of HTML. \`\`\` sse

Heading

Some paragraph...

\`\`\` Below this line is a codeblock of the same HTML that should be ignored and preserved. \`\`\` html

Heading

Some paragraph...

\`\`\` `; it.each` fn | initial | target ${'wrap'} | ${source} | ${sourceTemplated} ${'wrap'} | ${sourceTemplated} | ${sourceTemplated} ${'unwrap'} | ${sourceTemplated} | ${source} ${'unwrap'} | ${source} | ${source} `( 'wraps $initial in a templated sse codeblocks if $fn is wrap, unwraps otherwise', ({ fn, initial, target }) => { expect(templater[fn](initial)).toMatch(target); }, ); });