Skip to content

Commit

Permalink
Merge branch 'topics/20642-remark-prismjs-plugin' of https://github.c…
Browse files Browse the repository at this point in the history
…om/rbelow/gatsby into topics/20642-remark-prismjs-plugin
  • Loading branch information
Rubén Below committed Feb 24, 2020
2 parents a6b52bb + a9f6909 commit eaf1691
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ package-lock.json
!themes/gatsby-starter-notes-theme/package-lock.json
!themes/gatsby-starter-theme/package-lock.json
!themes/gatsby-starter-theme-workspace/package-lock.json

# Dev files
.local
.trash
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-mdx/utils/default-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = ({ mdPlugins, hastPlugins, ...pluginOptions }) => {
remarkPlugins: [],
plugins: [],
root: process.cwd(),
gatsbyRemarkPlugins: [],
gatsbyRemarkPlugins: [], // TODO:
globalScope: `export default {}`,
shouldBlockNodeFromTransformation: () => false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = async function getSourcePluginsAsRemarkPlugins({

fileNodes = getNodes().filter(n => n.internal.type === `File`)

// TODO:
// return list of remarkPlugins
const userPlugins = gatsbyRemarkPlugins
.filter(plugin => {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-remark-prismjs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.js
/plugins
/lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const loadPrismShowInvisibles = require(`../../plugins/prism-show-invisibles`)

// https://artsy.github.io/blog/2018/08/24/How-to-debug-jest-tests/
// yarn jest:inspect ./gatsby/packages/gatsby-remark-prismjs/src/__tests__/plugins/prism-show-invisibles.js
// yarn jest ./gatsby/packages/gatsby-remark-prismjs/src/__tests__/plugins/prism-show-invisibles.js
describe(`prism-show-invisibles`, () => {
test(`should export a function`, () => {
console.log(`here it comes:`, typeof loadPrismShowInvisibles)
expect(typeof loadPrismShowInvisibles).toBe(`function`)
})

test(`should not return`, () => {
expect(loadPrismShowInvisibles()).toBeUndefined()
})

test(`should return when global is undefined`, () => {
// eslint-disable-next-line no-global-assign
global = undefined
expect(loadPrismShowInvisibles()).toBeNull()
})

test(`should not be a mock`, () => {
expect(loadPrismShowInvisibles._isMockFunction).toBeFalsy()
})

test(`plays video`, () => {
const spy = jest.spyOn(loadPrismShowInvisibles, `addInvisibles`)
const isPlaying = loadPrismShowInvisibles.addInvisibles()

expect(spy).toHaveBeenCalled()
expect(isPlaying).toBe(true)

spy.mockRestore()
})

// TODO:
// [] See what I can test
// [] Test it!
// [] Debug Jest
// [] Export functionality?
// [] See how the other Prism plugins use Jest
// [] Jest spy
// [] Jest inject mock on spy
})

0 comments on commit eaf1691

Please sign in to comment.