Skip to content

Commit

Permalink
test: add test for supplying object config via node api
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 14, 2019
1 parent 5208399 commit d1da3fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/__snapshots__/index.spec.js.snap
Expand Up @@ -78,6 +78,15 @@ ERROR Please make sure you have created it correctly.
See https://github.com/okonet/lint-staged#configuration."
`;
exports[`lintStaged should use config object 1`] = `
"
LOG Running lint-staged with the following config:
LOG {
'*': 'node -e \\"process.exit(1)\\"'
}
ERROR Unable to get staged files!"
`;
exports[`lintStaged should use cosmiconfig if no params are passed 1`] = `
"
ERROR Unable to get staged files!"
Expand Down
9 changes: 9 additions & 0 deletions test/index.spec.js
Expand Up @@ -120,6 +120,15 @@ describe('lintStaged', () => {
expect(logger.printHistory()).toMatchSnapshot()
})

it('should use config object', async () => {
const config = {
'*': 'node -e "process.exit(1)"'
}
expect.assertions(1)
await lintStaged({ config, debug: true, quiet: true }, logger)
expect(logger.printHistory()).toMatchSnapshot()
})

it('should load an npm config package when specified', async () => {
expect.assertions(1)
jest.mock('my-lint-staged-config')
Expand Down

0 comments on commit d1da3fc

Please sign in to comment.