Skip to content

Commit

Permalink
feat(schematics): remove skipTests for actions
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

The `skipTests` option is removed while generating actions.
Action spec files are not generated.
  • Loading branch information
timdeschryver committed Feb 19, 2022
1 parent b60595d commit 6de2ef9
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 115 deletions.

This file was deleted.

37 changes: 9 additions & 28 deletions modules/schematics/src/action/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,29 @@ describe('Action Schematic', () => {
.toPromise();
const files = tree.files;
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.actions.ts`)
).toBeTruthy();
});

it('should create one file', async () => {
const tree = await schematicRunner
.runSchematicAsync('action', defaultOptions, appTree)
.toPromise();
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
tree.files.includes(`${projectPath}/src/app/foo.actions.ts`)
).toBeTruthy();
});

it('should create two files test files by default', async () => {
it('should not create test files', async () => {
const options = {
...defaultOptions,
};
const tree = await schematicRunner
.runSchematicAsync('action', options, appTree)
.toPromise();
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
});

it('should not create test files when skipTests is set to true', async () => {
const options = {
...defaultOptions,
skipTests: true,
};
const tree = await schematicRunner
.runSchematicAsync('action', options, appTree)
.toPromise();
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
).toEqual(-1);
expect(
tree.files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
tree.files.includes(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBe(false);
});

it('should create a const for the action creator', async () => {
Expand Down Expand Up @@ -165,8 +146,8 @@ describe('Action Schematic', () => {
)
.toPromise();
expect(
tree.files.indexOf(`${projectPath}/src/app/actions/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
tree.files.includes(`${projectPath}/src/app/actions/foo.actions.ts`)
).toBeTruthy();
});

it('should create a success class based on the provided name, given api', async () => {
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
move,
noop,
url,
Tree,
SchematicContext,
Expand All @@ -31,9 +29,6 @@ export default function (options: ActionOptions): Rule {
options.path = parsedPath.path;

const templateSource = apply(url('./files'), [
options.skipTests
? filter((path) => !path.endsWith('.spec.ts.template'))
: noop(),
applyTemplates({
...stringUtils,
'if-flat': (s: string) =>
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/action/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"description": "The name of the project.",
"aliases": ["p"]
},
"skipTests": {
"type": "boolean",
"description": "When true, does not create test files.",
"default": false
},
"flat": {
"type": "boolean",
"default": true,
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/action/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ export interface Schema {
*/
project?: string;

/**
* When true, does not create test files.
*/
skipTests?: boolean;

/**
* Flag to indicate if a dir is created.
*/
Expand Down
130 changes: 65 additions & 65 deletions modules/schematics/src/feature/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ describe('Feature Schematic', () => {
.toPromise();
const files = tree.files;
expect(
files.indexOf(`${projectPath}/src/app/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.actions.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeFalsy();
expect(
files.indexOf(`${projectPath}/src/app/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.reducer.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.reducer.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.reducer.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.effects.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.effects.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.effects.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.effects.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.selectors.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.selectors.spec.ts`)
).toBeTruthy();
});

it('should not create test files', async () => {
Expand All @@ -72,29 +72,29 @@ describe('Feature Schematic', () => {
.toPromise();
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
);
files.includes(`${projectPath}/src/app/foo.actions.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
expect(files.indexOf(`${projectPath}/src/app/foo.reducer.spec.ts`)).toEqual(
-1
);
files.includes(`${projectPath}/src/app/foo.actions.spec.ts`)
).toBeFalsy();
expect(
files.indexOf(`${projectPath}/src/app/foo.effects.ts`)
).toBeGreaterThanOrEqual(0);
expect(files.indexOf(`${projectPath}/src/app/foo.effects.spec.ts`)).toEqual(
-1
);
files.includes(`${projectPath}/src/app/foo.reducer.ts`)
).toBeTruthy();
expect(
files.includes(`${projectPath}/src/app/foo.reducer.spec.ts`)
).toBeFalsy();
expect(
files.includes(`${projectPath}/src/app/foo.effects.ts`)
).toBeTruthy();
expect(
files.includes(`${projectPath}/src/app/foo.effects.spec.ts`)
).toBeFalsy();
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/foo.selectors.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/foo.selectors.spec.ts`)
).toEqual(-1);
files.includes(`${projectPath}/src/app/foo.selectors.spec.ts`)
).toBeFalsy();
});

it('should create all files of a feature to specified project if provided', async () => {
Expand All @@ -113,29 +113,29 @@ describe('Feature Schematic', () => {
.toPromise();
const files = tree.files;
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.actions.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.actions.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.actions.spec.ts`)
).toBeFalsy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.reducer.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.reducer.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.reducer.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.effects.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.effects.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.effects.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.effects.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.selectors.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.selectors.ts`)
).toBeTruthy();
expect(
files.indexOf(`${specifiedProjectPath}/src/lib/foo.selectors.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${specifiedProjectPath}/src/lib/foo.selectors.spec.ts`)
).toBeTruthy();
});

it('should create all files of a feature within grouped folders if group is set', async () => {
Expand All @@ -146,26 +146,26 @@ describe('Feature Schematic', () => {
.toPromise();
const files = tree.files;
expect(
files.indexOf(`${projectPath}/src/app/actions/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/actions/foo.actions.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/reducers/foo.reducer.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/reducers/foo.reducer.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/reducers/foo.reducer.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/reducers/foo.reducer.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/effects/foo.effects.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/effects/foo.effects.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/effects/foo.effects.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/effects/foo.effects.spec.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/selectors/foo.selectors.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/selectors/foo.selectors.ts`)
).toBeTruthy();
expect(
files.indexOf(`${projectPath}/src/app/selectors/foo.selectors.spec.ts`)
).toBeGreaterThanOrEqual(0);
files.includes(`${projectPath}/src/app/selectors/foo.selectors.spec.ts`)
).toBeTruthy();
});

it('should respect the path provided for the feature name', async () => {
Expand Down

0 comments on commit 6de2ef9

Please sign in to comment.