Skip to content

Commit

Permalink
fix: code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron committed Aug 13, 2020
1 parent 658d01e commit 62dcf37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ plugins: [
resolve: `@adobe/gatsby-source-github-file-contributors`,
options: {
pages: {
paths: ['src/pages'],
extensions: ['md']
root: '', // root of the page paths (below) in the Github repo
paths: ['src/pages'], // relative path of the pages from the config
extensions: ['md'] // page extensions to filter for
},
repo: {
token: process.env.GITHUB_TOKEN,
owner: process.env.GITHUB_REPO_OWNER,
name: process.env.GITHUB_REPO_NAME,
token: process.env.GITHUB_TOKEN, // Github Personal Access Token
owner: process.env.GITHUB_REPO_OWNER, // user or org name
name: process.env.GITHUB_REPO_NAME,
branch: process.env.GITHUB_REPO_BRANCH
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/gatsby-node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ test('sourceNodes', async () => {
expect(gatsbyHelpers.actions.createNode).toHaveBeenCalledTimes(pages.length)
expect(mockGithubFetchContributors).toHaveBeenCalledTimes(pages.length)

options.root = 'my-root' // coverage
mockGlobby.mockResolvedValueOnce([])
await expect(gatsbyNode.sourceNodes(gatsbyHelpers, options)).resolves.toEqual(undefined)
expect(gatsbyHelpers.actions.createNode).toHaveBeenCalledTimes(pages.length)
expect(mockGithubFetchContributors).toHaveBeenCalledTimes(pages.length)

pages.forEach((page, index) => {
const { owner, name, branch, token } = options.repo
expect(mockGithubFetchContributors).toHaveBeenNthCalledWith(index + 1, owner, name, branch, page, token)
Expand Down

0 comments on commit 62dcf37

Please sign in to comment.