import { oneLineTrim, stripIndent } from 'common-tags'; describe('Markdown widget code block', () => { before(() => { Cypress.config('defaultCommandTimeout', 4000); cy.task('setupBackend', { backend: 'test' }); }); beforeEach(() => { cy.loginAndNewPost(); cy.clearMarkdownEditorContent(); }); after(() => { cy.task('teardownBackend', { backend: 'test' }); }); describe('code block', () => { it('outputs code', () => { // eslint-disable-next-line cypress/no-unnecessary-waiting cy .insertCodeBlock() .type('foo') .enter() .type('bar') .confirmMarkdownEditorContent( ` ${codeBlock(` foo bar `)} `, ) .wait(500) .clickModeToggle().confirmMarkdownEditorContent(` ${codeBlockRaw(` foo bar `)} `); }); }); }); function codeBlockRaw(content) { return ['```', ...stripIndent(content).split('\n'), '```'] .map( line => oneLineTrim`
${line}
xxxxxxxxxx