Skip to content

Commit c4c2cfd

Browse files
committed
test: make config loader tests more explicit
1 parent 298b55c commit c4c2cfd

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"name": "my-lint-staged-config",
3-
"version": "0.0.0"
3+
"version": "0.0.0",
4+
"type": "commonjs",
5+
"main": "./index.cjs"
46
}

test/index.spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('lintStaged', () => {
149149
`)
150150
})
151151

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

155155
await lintStaged(
@@ -171,6 +171,28 @@ describe('lintStaged', () => {
171171
`)
172172
})
173173

174+
it('should parse function linter from relative CJS config', async () => {
175+
expect.assertions(1)
176+
177+
await lintStaged(
178+
{
179+
configPath: path.join('test', '__mocks__', 'advanced-config.js'),
180+
debug: true,
181+
quiet: true,
182+
},
183+
logger
184+
)
185+
186+
expect(logger.printHistory()).toMatchInlineSnapshot(`
187+
"
188+
LOG Running lint-staged with the following config:
189+
LOG {
190+
'*.css': [Function: *.css],
191+
'*.js': [Function: *.js]
192+
}"
193+
`)
194+
})
195+
174196
it('should use config object', async () => {
175197
expect.assertions(1)
176198

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

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

187209
jest.mock('my-lint-staged-config')

0 commit comments

Comments
 (0)