Skip to content

Commit d70dd20

Browse files
committed
WIP tests for add and add --all
For this PR: microsoft#1434
1 parent e6ccacf commit d70dd20

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

apps/rush-lib/src/cli/test/RushCommandLineParser.test.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "a",
3+
"version": "1.0.0",
4+
"description": "Test package a"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "b",
3+
"version": "1.0.0",
4+
"description": "Test package b"
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"npmVersion": "6.4.1",
3+
"rushVersion": "5.5.2",
4+
"projectFolderMinDepth": 1,
5+
"projectFolderMaxDepth": 99,
6+
7+
"projects": [
8+
{
9+
"packageName": "a",
10+
"projectFolder": "a"
11+
},
12+
{
13+
"packageName": "b",
14+
"projectFolder": "b"
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)