Skip to content

Commit

Permalink
added test case
Browse files Browse the repository at this point in the history
  • Loading branch information
santoshyadavdev committed Mar 5, 2019
1 parent 166eabe commit ca25fe4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions modules/schematics/src/entity/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('Entity Schematic', () => {

const tree = schematicRunner.runSchematic('entity', options, appTree);
const files = tree.files;

expect(
files.indexOf(`${projectPath}/src/app/foo/actions/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
Expand All @@ -146,6 +147,7 @@ describe('Entity Schematic', () => {

const tree = schematicRunner.runSchematic('entity', options, appTree);
const files = tree.files;

expect(
files.indexOf(`${projectPath}/src/app/actions/foo.actions.ts`)
).toBeGreaterThanOrEqual(0);
Expand All @@ -159,4 +161,34 @@ describe('Entity Schematic', () => {
files.indexOf(`${projectPath}/src/app/reducers/foo.reducer.spec.ts`)
).toBeGreaterThanOrEqual(0);
});

it('should create all files of an entity within grouped and nested folders', () => {
const options = {
...defaultOptions,
name: 'user',
reducers: 'reducers/index.ts',
spec: true,
};

const reducerTree = schematicRunner.runSchematic('store', options, appTree);
const tree = schematicRunner.runSchematic('entity', options, appTree);
const files = tree.files;
const content = tree.readContent(
`${projectPath}/src/app/reducers/index.ts`
);
expect(
files.indexOf(`${projectPath}/src/app/user.actions.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/user.model.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/user.reducer.ts`)
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf(`${projectPath}/src/app/user.reducer.spec.ts`)
).toBeGreaterThanOrEqual(0);
expect(content).toMatch(/users\: fromUser.State/);
expect(content).toMatch(/users\: fromUser.reducer/);
});
});

0 comments on commit ca25fe4

Please sign in to comment.