Skip to content

Commit

Permalink
test: make config loader tests more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 21, 2021
1 parent 298b55c commit c4c2cfd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/__mocks__/my-lint-staged-config/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "my-lint-staged-config",
"version": "0.0.0"
"version": "0.0.0",
"type": "commonjs",
"main": "./index.cjs"
}
26 changes: 24 additions & 2 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('lintStaged', () => {
`)
})

it('should parse function linter from js config', async () => {
it('should parse function linter from absolute CJS config', async () => {
expect.assertions(1)

await lintStaged(
Expand All @@ -171,6 +171,28 @@ describe('lintStaged', () => {
`)
})

it('should parse function linter from relative CJS config', async () => {
expect.assertions(1)

await lintStaged(
{
configPath: path.join('test', '__mocks__', 'advanced-config.js'),
debug: true,
quiet: true,
},
logger
)

expect(logger.printHistory()).toMatchInlineSnapshot(`
"
LOG Running lint-staged with the following config:
LOG {
'*.css': [Function: *.css],
'*.js': [Function: *.js]
}"
`)
})

it('should use config object', async () => {
expect.assertions(1)

Expand All @@ -181,7 +203,7 @@ describe('lintStaged', () => {
expect(logger.printHistory()).toMatchInlineSnapshot(`""`)
})

it('should load an npm config package when specified', async () => {
it('should load a CJS module when specified', async () => {
expect.assertions(1)

jest.mock('my-lint-staged-config')
Expand Down

0 comments on commit c4c2cfd

Please sign in to comment.