Skip to content

Commit

Permalink
fix(schematics): use skipTests flag consistently, deprecate skipTest …
Browse files Browse the repository at this point in the history
…option (#2522)

Closes #2521
  • Loading branch information
aszechlicki committed May 27, 2020
1 parent 2972980 commit 83033d7
Show file tree
Hide file tree
Showing 44 changed files with 213 additions and 33 deletions.
8 changes: 4 additions & 4 deletions modules/effects/schematics/ng-add/index.spec.ts
Expand Up @@ -124,8 +124,8 @@ describe('Effects ng-add Schematic', () => {
expect(thrownError).toBeDefined();
});

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

const tree = schematicRunner.runSchematic('ng-add', options, appTree);
const files = tree.files;
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('Effects ng-add Schematic', () => {
const options = {
...defaultOptions,
flat: true,
skipTest: true,
skipTests: true,
group: true,
};

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

it('should inject the effect service correctly', async () => {
const options = { ...defaultOptions, skipTest: false };
const options = { ...defaultOptions, skipTests: false };
const tree = await schematicRunner
.runSchematicAsync('ng-add', options, appTree)
.toPromise();
Expand Down
6 changes: 5 additions & 1 deletion modules/effects/schematics/ng-add/index.ts
Expand Up @@ -124,12 +124,16 @@ export default function(options: EffectOptions): Rule {
options.module = findModuleFromOptions(host, options);
}

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

const parsedPath = parseName(options.path, options.name || '');
options.name = parsedPath.name;
options.path = parsedPath.path;

const templateSource = apply(url('./files'), [
options.skipTest
options.skipTests
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
options.minimal ? filter(_ => false) : noop(),
Expand Down
6 changes: 6 additions & 0 deletions modules/effects/schematics/ng-add/schema.json
Expand Up @@ -27,6 +27,12 @@
"description": "Flag to indicate if a dir is created."
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"default": false,
"description": "When true, does not create test files."
Expand Down
2 changes: 2 additions & 0 deletions modules/effects/schematics/ng-add/schema.ts
Expand Up @@ -3,7 +3,9 @@ export interface Schema {
skipPackageJson?: boolean;
path?: string;
flat?: boolean;
/** @deprecated renamed to skipTests, use skipTests instead */
skipTest?: boolean;
skipTests?: boolean;
project?: string;
module?: string;
group?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions modules/schematics/src/action/index.spec.ts
Expand Up @@ -73,15 +73,15 @@ describe('Action Schematic', () => {
).toBeGreaterThanOrEqual(0);
});

it('should not create two files test files when skipTests is set to true', () => {
it('should not create test files when skipTests is set to true', () => {
const options = {
...defaultOptions,
skipTests: false,
skipTests: true,
};
const tree = schematicRunner.runSchematic('action', options, appTree);
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
).toEqual(-1);
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
Expand Down
4 changes: 4 additions & 0 deletions modules/schematics/src/action/index.ts
Expand Up @@ -25,6 +25,10 @@ export default function(options: ActionOptions): Rule {
return (host: Tree, context: SchematicContext) => {
options.path = getProjectPath(host, options);

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
Expand Down
6 changes: 6 additions & 0 deletions modules/schematics/src/action/schema.json
Expand Up @@ -25,6 +25,12 @@
"aliases": ["p"]
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"description": "When true, does not create test files.",
"default": false
Expand Down
5 changes: 5 additions & 0 deletions modules/schematics/src/action/schema.ts
Expand Up @@ -14,6 +14,11 @@ export interface Schema {
*/
project?: string;

/**
* When true, does not create test files.
* @deprecated Use skipTests instead
*/
skipTest?: boolean;
/**
* When true, does not create test files.
*/
Expand Down
6 changes: 5 additions & 1 deletion modules/schematics/src/container/index.ts
Expand Up @@ -122,6 +122,10 @@ export default function(options: ContainerOptions): Rule {
return (host: Tree, context: SchematicContext) => {
options.path = getProjectPath(host, options);

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
Expand All @@ -136,7 +140,7 @@ export default function(options: ContainerOptions): Rule {
const templateSource = apply(
url(options.testDepth === 'unit' ? './files' : './integration-files'),
[
options.skipTest
options.skipTests
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
applyTemplates({
Expand Down
6 changes: 6 additions & 0 deletions modules/schematics/src/container/schema.json
Expand Up @@ -58,6 +58,12 @@
"type": "string"
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"description": "When true, does not create test files."
},
Expand Down
5 changes: 5 additions & 0 deletions modules/schematics/src/container/schema.ts
Expand Up @@ -37,8 +37,13 @@ export interface Schema {
style?: string;
/**
* When true, does not create test files.
* @deprecated Use skipTests instead
*/
skipTest?: boolean;
/**
* When true, does not create test files.
*/
skipTests?: boolean;
/**
* Flag to indicate if a dir is created.
*/
Expand Down
2 changes: 1 addition & 1 deletion modules/schematics/src/data/index.spec.ts
Expand Up @@ -59,7 +59,7 @@ describe('Data Schematic', () => {
).toBeGreaterThanOrEqual(0);
});

it('should create two files if skipTest is false(as it is by default)', () => {
it('should create two files if skipTests is false(as it is by default)', () => {
const options = {
...defaultOptions,
};
Expand Down
6 changes: 5 additions & 1 deletion modules/schematics/src/data/index.ts
Expand Up @@ -23,12 +23,16 @@ export default function(options: DataOptions): Rule {
return (host: Tree, context: SchematicContext) => {
options.path = getProjectPath(host, options);

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;

const templateSource = apply(url('./files'), [
options.skipTest
options.skipTests
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
applyTemplates({
Expand Down
6 changes: 6 additions & 0 deletions modules/schematics/src/data/schema.json
Expand Up @@ -24,6 +24,12 @@
"aliases": ["p"]
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"description": "When true, does not create test files.",
"default": false
Expand Down
5 changes: 5 additions & 0 deletions modules/schematics/src/data/schema.ts
Expand Up @@ -16,8 +16,13 @@ export interface Schema {

/**
* When true, does not create test files.
* @deprecated use skipTests instead
*/
skipTest?: boolean;
/**
* When true, does not create test files.
*/
skipTests?: boolean;

/**
* Flag to indicate if a dir is created.
Expand Down
8 changes: 4 additions & 4 deletions modules/schematics/src/effect/index.spec.ts
Expand Up @@ -103,8 +103,8 @@ describe('Effect Schematic', () => {
expect(thrownError).toBeDefined();
});

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

const tree = schematicRunner.runSchematic('effect', options, appTree);
const files = tree.files;
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('Effect Schematic', () => {
const options = {
...defaultOptions,
flat: true,
skipTest: true,
skipTests: true,
group: true,
};

Expand All @@ -257,7 +257,7 @@ describe('Effect Schematic', () => {
it('should group and nest the effect within a feature', () => {
const options = {
...defaultOptions,
skipTest: true,
skipTests: true,
group: true,
flat: false,
feature: true,
Expand Down
6 changes: 5 additions & 1 deletion modules/schematics/src/effect/index.ts
Expand Up @@ -121,6 +121,10 @@ export default function(options: EffectOptions): Rule {
return (host: Tree, context: SchematicContext) => {
options.path = getProjectPath(host, options);

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

if (options.module) {
options.module = findModuleFromOptions(host, options);
}
Expand All @@ -130,7 +134,7 @@ export default function(options: EffectOptions): Rule {
options.path = parsedPath.path;

const templateSource = apply(url('./files'), [
options.skipTest
options.skipTests
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
options.root && options.minimal ? filter(_ => false) : noop(),
Expand Down
6 changes: 6 additions & 0 deletions modules/schematics/src/effect/schema.json
Expand Up @@ -30,6 +30,12 @@
"description": "Flag to indicate if a dir is created."
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"default": false,
"description": "When true, does not create test files."
Expand Down
5 changes: 5 additions & 0 deletions modules/schematics/src/effect/schema.ts
Expand Up @@ -21,8 +21,13 @@ export interface Schema {

/**
* When true, does not create test files.
* @deprecated Use skipTests instead
*/
skipTest?: boolean;
/**
* When true, does not create test files.
*/
skipTests?: boolean;

/**
* Allows specification of the declaring module.
Expand Down
6 changes: 5 additions & 1 deletion modules/schematics/src/entity/index.ts
Expand Up @@ -33,6 +33,10 @@ export default function(options: EntityOptions): Rule {
options.name = parsedPath.name;
options.path = parsedPath.path;

if (!options.skipTests && options.skipTest) {
options.skipTests = options.skipTest;
}

if (options.module) {
options.module = findModuleFromOptions(host, options);
}
Expand All @@ -51,7 +55,7 @@ export default function(options: EntityOptions): Rule {
};

const commonTemplates = apply(url('./common-files'), [
options.skipTest
options.skipTests
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
applyTemplates(templateOptions),
Expand Down
6 changes: 6 additions & 0 deletions modules/schematics/src/entity/schema.json
Expand Up @@ -25,6 +25,12 @@
"aliases": ["p"]
},
"skipTest": {
"type": "boolean",
"description": "When true, does not create test files.",
"x-deprecated": "Use skipTests instead.",
"default": false
},
"skipTests": {
"type": "boolean",
"description": "When true, does not create test files.",
"default": false
Expand Down
5 changes: 5 additions & 0 deletions modules/schematics/src/entity/schema.ts
Expand Up @@ -19,8 +19,13 @@ export interface Schema {
flat?: boolean;
/**
* When true, does not create test files.
* @deprecated Use skipTests instead
*/
skipTest?: boolean;
/**
* When true, does not create test files.
*/
skipTests?: boolean;
/**
* Allows specification of the declaring module.
*/
Expand Down

0 comments on commit 83033d7

Please sign in to comment.