-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topics/20642-remark-prismjs-plugin' of https://github.c…
…om/rbelow/gatsby into topics/20642-remark-prismjs-plugin
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*.js | ||
/plugins | ||
/lib |
44 changes: 44 additions & 0 deletions
44
packages/gatsby-remark-prismjs/src/__tests__/plugins/prism-show-invisibles-copy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |