|
1 | 1 | import { ng } from '../../../utils/process'; |
2 | 2 | import { expectToFail } from '../../../utils/utils'; |
3 | 3 |
|
| 4 | +export default async function () { |
| 5 | + await expectToFail(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle')); |
| 6 | + await ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'false'); |
| 7 | + const { stdout } = await ng('config', 'schematics.@schematics/angular.component.inlineStyle'); |
| 8 | + if (!stdout.match(/false\n?/)) { |
| 9 | + throw new Error(`Expected "false", received "${JSON.stringify(stdout)}".`); |
| 10 | + } |
4 | 11 |
|
5 | | -export default function() { |
6 | | - return Promise.resolve() |
7 | | - .then(() => expectToFail(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle'))) |
8 | | - .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'false')) |
9 | | - .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle')) |
10 | | - .then(({ stdout }) => { |
11 | | - if (!stdout.match(/false\n?/)) { |
12 | | - throw new Error(`Expected "false", received "${JSON.stringify(stdout)}".`); |
13 | | - } |
14 | | - }) |
15 | | - .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'true')) |
16 | | - .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle')) |
17 | | - .then(({ stdout }) => { |
18 | | - if (!stdout.match(/true\n?/)) { |
19 | | - throw new Error(`Expected "true", received "${JSON.stringify(stdout)}".`); |
20 | | - } |
21 | | - }) |
22 | | - .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'false')) |
23 | | - .then(() => ng('config', `projects.test-project.architect.build.options.assets[0]`)) |
24 | | - .then(({ stdout }) => { |
25 | | - if (!stdout.includes('src/favicon.ico')) { |
26 | | - throw new Error(`Expected "src/favicon.ico", received "${JSON.stringify(stdout)}".`); |
27 | | - } |
28 | | - }) |
29 | | - .then(() => ng('config', `projects["test-project"].architect.build.options.assets[0]`)) |
30 | | - .then(({ stdout }) => { |
31 | | - if (!stdout.includes('src/favicon.ico')) { |
32 | | - throw new Error(`Expected "src/favicon.ico", received "${JSON.stringify(stdout)}".`); |
33 | | - } |
34 | | - }); |
| 12 | + await ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'true'); |
| 13 | + const { stdout: stdout1 } = await ng( |
| 14 | + 'config', |
| 15 | + 'schematics.@schematics/angular.component.inlineStyle', |
| 16 | + ); |
| 17 | + if (!stdout1.match(/true\n?/)) { |
| 18 | + throw new Error(`Expected "true", received "${JSON.stringify(stdout)}".`); |
| 19 | + } |
| 20 | + |
| 21 | + await ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'false'); |
| 22 | + const { stdout: stdout2 } = await ng( |
| 23 | + 'config', |
| 24 | + `projects.test-project.architect.build.options.assets[0]`, |
| 25 | + ); |
| 26 | + if (!stdout2.includes('src/favicon.ico')) { |
| 27 | + throw new Error(`Expected "src/favicon.ico", received "${JSON.stringify(stdout)}".`); |
| 28 | + } |
| 29 | + |
| 30 | + const { stdout: stdout3 } = await ng( |
| 31 | + 'config', |
| 32 | + `projects["test-project"].architect.build.options.assets[0]`, |
| 33 | + ); |
| 34 | + |
| 35 | + if (!stdout3.includes('src/favicon.ico')) { |
| 36 | + throw new Error(`Expected "src/favicon.ico", received "${JSON.stringify(stdout)}".`); |
| 37 | + } |
| 38 | + |
| 39 | + // should print all config when no positional args are provided. |
| 40 | + const { stdout: stdout4 } = await ng('config'); |
| 41 | + if (!stdout4.includes('$schema')) { |
| 42 | + throw new Error(`Expected to contain "$schema", received "${JSON.stringify(stdout)}".`); |
| 43 | + } |
35 | 44 | } |
0 commit comments