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 85d6bda
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin/awesoMD/plugin.js
Original file line number Diff line number Diff line change
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 85d6bda

Please sign in to comment.