Skip to content

Commit

Permalink
fix(@schematics/angular): respect the flag when we create a guard wit…
Browse files Browse the repository at this point in the history
…h schematics
  • Loading branch information
wKoza authored and alexeagle committed Feb 13, 2019
1 parent 32e3b7c commit 355a8e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/schematics/angular/guard/index.ts
Expand Up @@ -65,7 +65,7 @@ export default function (options: GuardOptions): Rule {
...strings,
...options,
}),
move(parsedPath.path),
move(parsedPath.path + (options.flat ? '' : '/' + strings.dasherize(options.name))),
]);

return chain([
Expand Down
9 changes: 9 additions & 0 deletions packages/schematics/angular/guard/index_spec.ts
Expand Up @@ -56,6 +56,15 @@ describe('Guard Schematic', () => {
expect(files).toContain('/projects/bar/src/app/foo.guard.ts');
});

it('should respect the flat flag', () => {
const options = { ...defaultOptions, flat: false };

const tree = schematicRunner.runSchematic('guard', options, appTree);
const files = tree.files;
expect(files).toContain('/projects/bar/src/app/foo/foo.guard.spec.ts');
expect(files).toContain('/projects/bar/src/app/foo/foo.guard.ts');
});

it('should respect the sourceRoot value', () => {
const config = JSON.parse(appTree.readContent('/angular.json'));
config.projects.bar.sourceRoot = 'projects/bar/custom';
Expand Down

0 comments on commit 355a8e6

Please sign in to comment.