Skip to content

Commit

Permalink
fix(Effects): Added defaults for ng-add schematic
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored and MikeRyanDev committed May 23, 2018
1 parent ff7dc72 commit 9d36016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions modules/effects/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Effect ng-add Schematic', () => {
skipPackageJson: false,
project: 'bar',
spec: true,
module: undefined,
module: 'app',
flat: false,
group: false,
};
Expand Down Expand Up @@ -66,14 +66,12 @@ describe('Effect ng-add Schematic', () => {
).toBeGreaterThanOrEqual(0);
});

it('should not be provided by default', () => {
it('should be provided by default', () => {
const options = { ...defaultOptions };

const tree = schematicRunner.runSchematic('ng-add', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
expect(content).not.toMatch(
/import { FooEffects } from '.\/foo\/foo.effects'/
);
expect(content).toMatch(/import { FooEffects } from '.\/foo\/foo.effects'/);
});

it('should import into a specified module', () => {
Expand Down Expand Up @@ -112,7 +110,7 @@ describe('Effect ng-add Schematic', () => {
});

it('should register the root effect in the provided module', () => {
const options = { ...defaultOptions, module: 'app.module.ts' };
const options = { ...defaultOptions };

const tree = schematicRunner.runSchematic('ng-add', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
Expand Down
6 changes: 3 additions & 3 deletions modules/effects/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ export default function(options: RootEffectOptions): Rule {
]);

return chain([
options && options.skipPackageJson
? noop()
: addNgRxEffectsToPackageJson(),
branchAndMerge(
chain([
filter(
Expand All @@ -150,6 +147,9 @@ export default function(options: RootEffectOptions): Rule {
mergeWith(templateSource),
])
),
options && options.skipPackageJson
? noop()
: addNgRxEffectsToPackageJson(),
])(host, context);
};
}
9 changes: 3 additions & 6 deletions modules/effects/schematics/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"name": {
"description": "The name of the effect.",
"type": "string",
"$default": {
"$source": "argv",
"index": 0
}
"default": "App"
},
"skipPackageJson": {
"type": "boolean",
Expand All @@ -21,7 +18,7 @@
"path": {
"type": "string",
"format": "path",
"description": "The path to create the component.",
"description": "The path to create the effect.",
"visible": false
},
"flat": {
Expand All @@ -36,7 +33,7 @@
},
"module": {
"type": "string",
"default": "",
"default": "app",
"description": "Allows specification of the declaring module.",
"alias": "m",
"subtype": "filepath"
Expand Down

0 comments on commit 9d36016

Please sign in to comment.