Skip to content

Commit

Permalink
fix(schematics): fix typo in option name
Browse files Browse the repository at this point in the history
rename skipTests option in action schematics to skipTest, consistent with naming in other schematics
pass option value instead of hardcoded true in feature schematics
update tests

fixes ngrx#2521
  • Loading branch information
Arkadiusz Szechlicki committed May 12, 2020
1 parent 534aa09 commit 8f8e188
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
6 changes: 3 additions & 3 deletions modules/schematics/src/action/index.spec.ts
Original file line number Diff line number Diff line change
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 skipTest is set to true', () => {
const options = {
...defaultOptions,
skipTests: false,
skipTest: 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
2 changes: 1 addition & 1 deletion modules/schematics/src/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function(options: ActionOptions): Rule {
const templateSource = apply(
url(options.creators ? './creator-files' : './files'),
[
options.skipTests
options.skipTest
? filter(path => !path.endsWith('.spec.ts.template'))
: noop(),
applyTemplates({
Expand Down
2 changes: 1 addition & 1 deletion modules/schematics/src/action/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface Schema {
/**
* When true, does not create test files.
*/
skipTests?: boolean;
skipTest?: boolean;

/**
* Flag to indicate if a dir is created.
Expand Down
37 changes: 37 additions & 0 deletions modules/schematics/src/feature/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ describe('Feature Schematic', () => {
expect(
files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
Expand All @@ -59,6 +62,37 @@ describe('Feature Schematic', () => {
).toBeGreaterThanOrEqual(0);
});

it('should not create test files', () => {
const options = { ...defaultOptions, skipTest: true };

const tree = schematicRunner.runSchematic('feature', options, appTree);
const files = tree.files;
expect(
files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
expect(files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)).toEqual(
-1
);
expect(
files.indexOf(`${projectPath}/src/app/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
expect(files.indexOf(`${projectPath}/src/app/foo.reducer.spec.ts`)).toEqual(
-1
);
expect(
files.indexOf(`${projectPath}/src/app/foo.effects.ts`)
).toBeGreaterThanOrEqual(0);
expect(files.indexOf(`${projectPath}/src/app/foo.effects.spec.ts`)).toEqual(
-1
);
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.spec.ts`)
).toEqual(-1);
});

it('should create all files of a feature to specified project if provided', () => {
const options = {
...defaultOptions,
Expand All @@ -75,6 +109,9 @@ describe('Feature Schematic', () => {
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
Expand Down
2 changes: 1 addition & 1 deletion modules/schematics/src/feature/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function(options: FeatureOptions): Rule {
name: options.name,
path: options.path,
project: options.project,
skipTest: true,
skipTest: options.skipTest,
api: options.api,
creators: options.creators,
}),
Expand Down

0 comments on commit 8f8e188

Please sign in to comment.