Skip to content

Commit 83033d7

Browse files
authored
fix(schematics): use skipTests flag consistently, deprecate skipTest option (#2522)
Closes #2521
1 parent 2972980 commit 83033d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+213
-33
lines changed

modules/effects/schematics/ng-add/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ describe('Effects ng-add Schematic', () => {
124124
expect(thrownError).toBeDefined();
125125
});
126126

127-
it('should respect the skipTest flag', () => {
128-
const options = { ...defaultOptions, skipTest: true };
127+
it('should respect the skipTests flag', () => {
128+
const options = { ...defaultOptions, skipTests: true };
129129

130130
const tree = schematicRunner.runSchematic('ng-add', options, appTree);
131131
const files = tree.files;
@@ -203,7 +203,7 @@ describe('Effects ng-add Schematic', () => {
203203
const options = {
204204
...defaultOptions,
205205
flat: true,
206-
skipTest: true,
206+
skipTests: true,
207207
group: true,
208208
};
209209

@@ -215,7 +215,7 @@ describe('Effects ng-add Schematic', () => {
215215
});
216216

217217
it('should inject the effect service correctly', async () => {
218-
const options = { ...defaultOptions, skipTest: false };
218+
const options = { ...defaultOptions, skipTests: false };
219219
const tree = await schematicRunner
220220
.runSchematicAsync('ng-add', options, appTree)
221221
.toPromise();

modules/effects/schematics/ng-add/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,16 @@ export default function(options: EffectOptions): Rule {
124124
options.module = findModuleFromOptions(host, options);
125125
}
126126

127+
if (!options.skipTests && options.skipTest) {
128+
options.skipTests = options.skipTest;
129+
}
130+
127131
const parsedPath = parseName(options.path, options.name || '');
128132
options.name = parsedPath.name;
129133
options.path = parsedPath.path;
130134

131135
const templateSource = apply(url('./files'), [
132-
options.skipTest
136+
options.skipTests
133137
? filter(path => !path.endsWith('.spec.ts.template'))
134138
: noop(),
135139
options.minimal ? filter(_ => false) : noop(),

modules/effects/schematics/ng-add/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
"description": "Flag to indicate if a dir is created."
2828
},
2929
"skipTest": {
30+
"type": "boolean",
31+
"description": "When true, does not create test files.",
32+
"x-deprecated": "Use skipTests instead.",
33+
"default": false
34+
},
35+
"skipTests": {
3036
"type": "boolean",
3137
"default": false,
3238
"description": "When true, does not create test files."

modules/effects/schematics/ng-add/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ export interface Schema {
33
skipPackageJson?: boolean;
44
path?: string;
55
flat?: boolean;
6+
/** @deprecated renamed to skipTests, use skipTests instead */
67
skipTest?: boolean;
8+
skipTests?: boolean;
79
project?: string;
810
module?: string;
911
group?: boolean;

modules/schematics/src/action/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ describe('Action Schematic', () => {
7373
).toBeGreaterThanOrEqual(0);
7474
});
7575

76-
it('should not create two files test files when skipTests is set to true', () => {
76+
it('should not create test files when skipTests is set to true', () => {
7777
const options = {
7878
...defaultOptions,
79-
skipTests: false,
79+
skipTests: true,
8080
};
8181
const tree = schematicRunner.runSchematic('action', options, appTree);
8282
expect(
8383
tree.files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
84-
).toBeGreaterThanOrEqual(0);
84+
).toEqual(-1);
8585
expect(
8686
tree.files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
8787
).toBeGreaterThanOrEqual(0);

modules/schematics/src/action/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export default function(options: ActionOptions): Rule {
2525
return (host: Tree, context: SchematicContext) => {
2626
options.path = getProjectPath(host, options);
2727

28+
if (!options.skipTests && options.skipTest) {
29+
options.skipTests = options.skipTest;
30+
}
31+
2832
const parsedPath = parseName(options.path, options.name);
2933
options.name = parsedPath.name;
3034
options.path = parsedPath.path;

modules/schematics/src/action/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
"aliases": ["p"]
2626
},
2727
"skipTest": {
28+
"type": "boolean",
29+
"description": "When true, does not create test files.",
30+
"x-deprecated": "Use skipTests instead.",
31+
"default": false
32+
},
33+
"skipTests": {
2834
"type": "boolean",
2935
"description": "When true, does not create test files.",
3036
"default": false

modules/schematics/src/action/schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export interface Schema {
1414
*/
1515
project?: string;
1616

17+
/**
18+
* When true, does not create test files.
19+
* @deprecated Use skipTests instead
20+
*/
21+
skipTest?: boolean;
1722
/**
1823
* When true, does not create test files.
1924
*/

modules/schematics/src/container/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export default function(options: ContainerOptions): Rule {
122122
return (host: Tree, context: SchematicContext) => {
123123
options.path = getProjectPath(host, options);
124124

125+
if (!options.skipTests && options.skipTest) {
126+
options.skipTests = options.skipTest;
127+
}
128+
125129
const parsedPath = parseName(options.path, options.name);
126130
options.name = parsedPath.name;
127131
options.path = parsedPath.path;
@@ -136,7 +140,7 @@ export default function(options: ContainerOptions): Rule {
136140
const templateSource = apply(
137141
url(options.testDepth === 'unit' ? './files' : './integration-files'),
138142
[
139-
options.skipTest
143+
options.skipTests
140144
? filter(path => !path.endsWith('.spec.ts.template'))
141145
: noop(),
142146
applyTemplates({

modules/schematics/src/container/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
"type": "string"
5959
},
6060
"skipTest": {
61+
"type": "boolean",
62+
"description": "When true, does not create test files.",
63+
"x-deprecated": "Use skipTests instead.",
64+
"default": false
65+
},
66+
"skipTests": {
6167
"type": "boolean",
6268
"description": "When true, does not create test files."
6369
},

0 commit comments

Comments
 (0)