Skip to content

Commit

Permalink
add unit test for showing error message in case data-markdown is prov…
Browse files Browse the repository at this point in the history
…ided with data-separator-by-heading
  • Loading branch information
PrajwolAmatya committed Jul 25, 2024
1 parent 60f69f3 commit 23cad6f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin/awesoMD/awesoMD.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin/awesoMD/awesoMD.js

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions plugin/awesoMD/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const plugin = () => {
}
}

if (animateLists === true) {
if (animateLists) {
renderer.listitem = (text) => `<li class="fragment">${text}</li>`
}

Expand Down Expand Up @@ -207,7 +207,13 @@ const plugin = () => {
// add slide separator in the case heading indicates the new slide
if (options.separateByHeading) {
if (options.hasDataSeparator) {
return '<section ' + options.attributes + ' data-markdown>' + 'Please do not specify "data-markdown" when "data-separator-by-heading" is used.' + '</section>'
return (
'<section ' +
options.attributes +
' data-markdown>' +
'Please do not specify "data-markdown" when "data-separator-by-heading" is used.' +
'</section>'
)
}
options['slideSeparator'] = '---'
markdown = this.addSlideSeparator(markdown, options)
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/jest/extractMetadata.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,20 @@ some content
expect(updatedMarkdownContent).toEqual(expectedMarkdownContent)
})
})

describe('slidify', () => {
it('should return error message when data-separator is provided with data-separator-by-heading', () => {
const options = {
separateByHeading: true,
hasDataSeparator: true,
}
const expectedMarkdownSection =
'<section data-markdown>' +
'Please do not specify "data-markdown" when "data-separator-by-heading" is used.' +
'</section>'

const markdownContent = fs.readFileSync('tests/unit/testFiles/noSlideSeparator.md', 'utf-8')
const returnedMarkdownSection = mdPlugin.slidify(markdownContent, { ...options })
expect(returnedMarkdownSection).toEqual(expectedMarkdownSection)
})
})

0 comments on commit 23cad6f

Please sign in to comment.