-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
4,345 additions
and
2,595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,82 @@ | ||
import { endent, mapValues } from '@dword-design/functions' | ||
import { endent } from '@dword-design/functions' | ||
import tester from '@dword-design/tester' | ||
import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir' | ||
import depcheck from 'depcheck' | ||
import outputFiles from 'output-files' | ||
import withLocalTmpDir from 'with-local-tmp-dir' | ||
|
||
import self from '.' | ||
import self from './index.js' | ||
|
||
const runTest = config => { | ||
config = { fail: false, ...config } | ||
|
||
return () => | ||
withLocalTmpDir(async () => { | ||
await outputFiles(config.files) | ||
|
||
const result = await depcheck('.', { | ||
package: { | ||
dependencies: { | ||
foo: '^1.0.0', | ||
}, | ||
}, | ||
specials: [self], | ||
}) | ||
expect(result.dependencies.length > 0).toEqual(config.fail) | ||
}) | ||
} | ||
|
||
export default { | ||
'array syntax': { | ||
files: { | ||
'nuxt.config.js': endent` | ||
export default tester( | ||
{ | ||
'array syntax': { | ||
files: { | ||
'nuxt.config.js': endent` | ||
export default { | ||
modules: [ | ||
['foo', { bar: 'baz' }], | ||
], | ||
} | ||
`, | ||
}, | ||
}, | ||
}, | ||
buildModules: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
buildModules: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
export default { | ||
buildModules: [ | ||
'foo', | ||
], | ||
} | ||
`, | ||
}, | ||
}, | ||
}, | ||
function: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
function: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
export default { | ||
modules: [ | ||
'foo', | ||
() => {}, | ||
], | ||
} | ||
`, | ||
}, | ||
}, | ||
}, | ||
modules: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
modules: { | ||
files: { | ||
'nuxt.config.js': endent` | ||
export default { | ||
modules: [ | ||
'foo', | ||
], | ||
} | ||
`, | ||
}, | ||
}, | ||
'unused dependency': { | ||
fail: true, | ||
}, | ||
}, | ||
'unused dependency': { | ||
fail: true, | ||
}, | ||
} |> mapValues(runTest) | ||
[ | ||
testerPluginTmpDir(), | ||
{ | ||
transform: config => { | ||
config = { fail: false, ...config } | ||
|
||
return async () => { | ||
await outputFiles(config.files) | ||
|
||
const result = await depcheck('.', { | ||
package: { | ||
dependencies: { | ||
foo: '^1.0.0', | ||
}, | ||
}, | ||
specials: [self], | ||
}) | ||
expect(result.dependencies.length > 0).toEqual(config.fail) | ||
} | ||
}, | ||
}, | ||
] | ||
) |
Oops, something went wrong.