Skip to content

Commit b70116e

Browse files
alan-agius4clydin
authored andcommitted
test(@angular/cli): extract version specifier e2e test
(cherry picked from commit d081974)
1 parent 0068783 commit b70116e

File tree

3 files changed

+48
-31
lines changed

3 files changed

+48
-31
lines changed

tests/legacy-cli/e2e/tests/commands/add/add-material.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,7 @@ export default async function () {
2121
await ng('add', `@angular/material${tag}`, '--theme', 'custom', '--verbose');
2222
await expectFileToMatch('package.json', /@angular\/material/);
2323

24-
const output1 = await ng('add', '@angular/material');
25-
if (!output1.stdout.includes('Skipping installation: Package already installed')) {
26-
throw new Error('Installation was not skipped');
27-
}
28-
2924
// Clean up existing cdk package
3025
// Not doing so can cause adding material to fail if an incompatible cdk is present
3126
await uninstallPackage('@angular/cdk');
32-
33-
const output2 = await ng('add', '@angular/material@latest');
34-
if (output2.stdout.includes('Skipping installation: Package already installed')) {
35-
throw new Error('Installation should not have been skipped');
36-
}
37-
38-
const output3 = await ng('add', '@angular/[email protected]');
39-
if (output3.stdout.includes('Skipping installation: Package already installed')) {
40-
throw new Error('Installation should not have been skipped');
41-
}
42-
43-
const output4 = await ng('add', '@angular/material@8');
44-
if (!output4.stdout.includes('Skipping installation: Package already installed')) {
45-
throw new Error('Installation was not skipped');
46-
}
4727
}

tests/legacy-cli/e2e/tests/commands/add/add-pwa.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { expectFileToExist, readFile, rimraf } from '../../../utils/fs';
33
import { ng } from '../../../utils/process';
44

55
export default async function () {
6-
// forcibly remove in case another test doesn't clean itself up
7-
await rimraf('node_modules/@angular/pwa');
8-
await ng('add', '@angular/pwa');
9-
await expectFileToExist(join(process.cwd(), 'src/manifest.webmanifest'));
6+
// forcibly remove in case another test doesn't clean itself up
7+
await rimraf('node_modules/@angular/pwa');
8+
await ng('add', '@angular/pwa');
9+
await expectFileToExist(join(process.cwd(), 'src/manifest.webmanifest'));
1010

11-
// Angular PWA doesn't install as a dependency
12-
const { dependencies, devDependencies } = JSON.parse(await readFile(join(process.cwd(), 'package.json')));
13-
const hasPWADep = Object.keys({ ...dependencies, ...devDependencies })
14-
.some(d => d === '@angular/pwa');
15-
if (hasPWADep) {
16-
throw new Error(`Expected 'package.json' not to contain a dependency on '@angular/pwa'.`);
17-
}
11+
// Angular PWA doesn't install as a dependency
12+
const { dependencies, devDependencies } = JSON.parse(await readFile(join(process.cwd(), 'package.json')));
13+
const hasPWADep = Object.keys({ ...dependencies, ...devDependencies })
14+
.some(d => d === '@angular/pwa');
15+
if (hasPWADep) {
16+
throw new Error(`Expected 'package.json' not to contain a dependency on '@angular/pwa'.`);
17+
}
1818
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { expectFileToMatch, rimraf } from '../../../utils/fs';
2+
import { uninstallPackage } from '../../../utils/packages';
3+
import { ng } from '../../../utils/process';
4+
import { isPrereleaseCli } from '../../../utils/project';
5+
6+
7+
export default async function () {
8+
// forcibly remove in case another test doesn't clean itself up.
9+
await rimraf('node_modules/@angular/localize');
10+
11+
const tag = await isPrereleaseCli() ? '@next' : '';
12+
13+
await ng('add', `@angular/localize${tag}`);
14+
await expectFileToMatch('package.json', /@angular\/localize/);
15+
16+
const output1 = await ng('add', '@angular/localize');
17+
if (!output1.stdout.includes('Skipping installation: Package already installed')) {
18+
throw new Error('Installation was not skipped');
19+
}
20+
21+
const output2 = await ng('add', '@angular/localize@latest');
22+
if (output2.stdout.includes('Skipping installation: Package already installed')) {
23+
throw new Error('Installation should not have been skipped');
24+
}
25+
26+
const output3 = await ng('add', '@angular/[email protected]');
27+
if (output3.stdout.includes('Skipping installation: Package already installed')) {
28+
throw new Error('Installation should not have been skipped');
29+
}
30+
31+
const output4 = await ng('add', '@angular/localize@10');
32+
if (!output4.stdout.includes('Skipping installation: Package already installed')) {
33+
throw new Error('Installation was not skipped');
34+
}
35+
36+
await uninstallPackage('@angular/localize');
37+
}

0 commit comments

Comments
 (0)