-
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.
Merge pull request #3 from narol1024/develop
fix: add unit testing
- Loading branch information
Showing
28 changed files
with
132 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,3 +115,4 @@ dist | |
.idea/ | ||
.vscode/ | ||
tools/dev | ||
.DS_Store |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { bootstrap } from '../cli'; | ||
|
||
bootstrap(); |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* This is a sample test suite. | ||
* Replace this with your implementation. | ||
*/ | ||
import { bootstrap } from './index'; | ||
|
||
describe('CLI tool Tests', () => { | ||
it('main', async () => { | ||
const spy = jest.spyOn(console, 'log'); | ||
const program = await bootstrap(['node', 'index.js', 'analyze', 'react']); | ||
await expect(program.commands.map((i: any) => i._name)).toEqual(['analyze']); | ||
const result = spy.mock.calls[0][0]; | ||
expect(result).toEqual( | ||
JSON.stringify( | ||
[ | ||
{ | ||
name: 'react', | ||
fanIn: 10000, | ||
fanOut: 1, | ||
stability: 0.00009999000099990002, | ||
label: 'Stable', | ||
}, | ||
], | ||
null, | ||
2, | ||
), | ||
); | ||
}); | ||
}); |
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,17 +1,19 @@ | ||
#!/usr/bin/env node | ||
import { Command } from 'commander'; | ||
import { analyze } from '../index'; | ||
|
||
const program = new Command(); | ||
|
||
program.name('sdp-analyzer').description('A cli tool for analyzing package stability').version('1.0.0'); | ||
program | ||
.command('analyze') | ||
.argument('<string>', 'the local package path or a npm package name') | ||
.action(async target => { | ||
const result = await analyze(target); | ||
console.log(JSON.stringify(result, null, 2)); | ||
process.exit(0); | ||
}); | ||
async function bootstrap(argv = process.argv) { | ||
program.name('sdp-analyzer').description('A cli tool for analyzing package stability').version('1.0.0'); | ||
program | ||
.command('analyze') | ||
.argument('<string>', 'the local package path or a npm package name') | ||
.action(async target => { | ||
const result = await analyze(target); | ||
console.log(JSON.stringify(result, null, 2)); | ||
}); | ||
await program.parseAsync(argv); | ||
return program; | ||
} | ||
|
||
program.parse(); | ||
export { bootstrap }; |
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 |
---|---|---|
|
@@ -15,13 +15,13 @@ describe('Npm pacakge Tests', () => { | |
{ name: 'loose-envify', version: '^1.1.0' }, | ||
]); | ||
}); | ||
it('can analyze for single package', async () => { | ||
it('can be analyzed for single package', async () => { | ||
await expect(analyze('react')).resolves.toMatchSnapshot(); | ||
}); | ||
it('can analyze for multiple packages', async () => { | ||
it('can be analyzed for multiple packages', async () => { | ||
await expect(analyze('react,vue')).resolves.toMatchSnapshot(); | ||
}); | ||
it('can analyze for multiple packages with the package version', async () => { | ||
it('can be analyzed for multiple packages with the package version', async () => { | ||
await expect(analyze('[email protected],[email protected]')).resolves.toMatchSnapshot(); | ||
}); | ||
}); |
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
1 change: 1 addition & 0 deletions
1
src/platforms/workspaces/yarn/fixture/invalid-packages/package.json
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.