Skip to content

Commit

Permalink
Add unit tests for custom deploy users (enriikke#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbach committed Apr 20, 2021
1 parent d6db945 commit 0f096c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ beforeAll(() => {
}
})

github.context.actor = 'enrikke'
github.context.ref = 'refs/heads/some-ref'
github.context.sha = '1234567890123456789012345678901234567890'

Expand Down Expand Up @@ -131,4 +132,26 @@ describe('Gatsby Publish action', () => {

expect(execSpy).toBeCalledWith('npm run build', [], {cwd: './__tests__'})
})

it('calls gatsby build with git name and email', async () => {
inputs['gatsby-args'] = ''
inputs['git-config-name'] = 'git-name'
inputs['git-config-email'] = 'git-email'
inputs['skip-publish'] = 'FALSE'

await run()

expect(execSpy).nthCalledWith(4, 'git config user.name', ['git-name'], {cwd: './public'})
expect(execSpy).nthCalledWith(5, 'git config user.email', ['git-email'], {cwd: './public'})
})

it('calls gatsby build without git name and email', async () => {
inputs['gatsby-args'] = ''
inputs['skip-publish'] = 'FALSE'

await run()

expect(execSpy).nthCalledWith(4, 'git config user.name', ['enrikke'], {cwd: './public'})
expect(execSpy).nthCalledWith(5, 'git config user.email', ['enrikke@users.noreply.github.com'], {cwd: './public'})
})
})

0 comments on commit 0f096c5

Please sign in to comment.