Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hexrcs committed Nov 27, 2018
1 parent 3b9598a commit 8e6131c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/gatsby-remark-katex/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,32 @@ describe(`remark katex plugin`, () => {
plugin({ markdownAST })
expect(markdownAST).toMatchSnapshot()
})

it(`doesn't crash when there's an error in development mode`, () => {
const equation = `$a^2 + b^2 = c^$`
let remark = new Remark()

expect(() => {
for (let parserPlugins of plugin.setParserPlugins()) {
remark = remark.use(parserPlugins)
}
process.env.gatsby_executing_command = `develop`
const markdownAST = remark.parse(equation)
plugin({ markdownAST })
}).not.toThrow()
})

it(`crashes when there's an error in build mode`, () => {
const equation = `$a^2 + b^2 = c^$`
let remark = new Remark()

expect(() => {
for (let parserPlugins of plugin.setParserPlugins()) {
remark = remark.use(parserPlugins)
}
process.env.gatsby_executing_command = `build`
const markdownAST = remark.parse(equation)
plugin({ markdownAST })
}).toThrow()
})
})

0 comments on commit 8e6131c

Please sign in to comment.