@@ -39,7 +39,7 @@ interface IParserTestInstance {
3939/**
4040 * Helper to set up a test instance for RushCommandLineParser.
4141 */
42- function getCommandLineParserInstance ( repoName : string , taskName : string ) : IParserTestInstance {
42+ function getCommandLineParserInstance ( repoName : string , taskName : string , ... otherParams : string [ ] ) : IParserTestInstance {
4343 // Point to the test repo folder
4444 const startPath : string = resolve ( __dirname , repoName ) ;
4545
@@ -55,7 +55,7 @@ function getCommandLineParserInstance(repoName: string, taskName: string): IPars
5555 const parser : RushCommandLineParser = new RushCommandLineParser ( { cwd : startPath } ) ;
5656
5757 // Mock the command
58- process . argv = [ 'pretend-this-is-node.exe' , 'pretend-this-is-rush' , taskName ] ;
58+ process . argv = [ 'pretend-this-is-node.exe' , 'pretend-this-is-rush' , taskName , ... otherParams ] ;
5959 const spawnMock : jest . Mock = setSpawnMock ( ) ;
6060
6161 return {
@@ -279,4 +279,21 @@ describe('RushCommandLineParser', () => {
279279 } ) ;
280280 } ) ;
281281 } ) ;
282- } ) ;
282+
283+ describe ( `in repo with tests for add` , ( ) => {
284+ describe ( `'add' action` , ( ) => {
285+ it ( `adds a dependency to just one sub-repo` , ( ) => {
286+ const repoName : string = 'addRepo' ;
287+ const instance : IParserTestInstance = getCommandLineParserInstance ( repoName , 'add' , 'assert' , '-t' , 'a' ) ;
288+
289+ expect . assertions ( 1 ) ;
290+ return expect ( instance . parser . execute ( ) ) . resolves . toEqual ( true )
291+ . then ( ( ) => {
292+ // There should be 1 build per package
293+ const packageCount : number = instance . spawnMock . mock . calls . length ;
294+ expect ( packageCount ) . toEqual ( 1 ) ;
295+ } ) ;
296+ } ) ;
297+ } ) ;
298+ } ) ;
299+ } ) ;
0 commit comments