Skip to content

Commit 9cd8be6

Browse files
phhien203filipesilva
authored andcommitted
test(@schematics/angular): add missing unit test for skipTests flag of component, class, directive, and pipe
1 parent 5d15e5d commit 9cd8be6

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

packages/schematics/angular/class/index_spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,14 @@ describe('Class Schematic', () => {
9999
appTree = await schematicRunner.runSchematicAsync('class', defaultOptions, appTree).toPromise();
100100
expect(appTree.files).toContain('/projects/bar/custom/app/foo.ts');
101101
});
102+
103+
it('should respect the skipTests flag', async () => {
104+
const options = {
105+
...defaultOptions,
106+
skipTests: true,
107+
};
108+
const tree = await schematicRunner.runSchematicAsync('class', options, appTree).toPromise();
109+
expect(tree.files).toContain('/projects/bar/src/app/foo.ts');
110+
expect(tree.files).not.toContain('/projects/bar/src/app/foo.spec.ts');
111+
});
102112
});

packages/schematics/angular/component/index_spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,19 @@ describe('Component Schematic', () => {
365365
.toPromise();
366366
expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.component.ts');
367367
});
368+
369+
it('should respect the skipTests option', async () => {
370+
const options = { ...defaultOptions, skipTests: true };
371+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
372+
const files = tree.files;
373+
374+
expect(files).toEqual(
375+
jasmine.arrayContaining([
376+
'/projects/bar/src/app/foo/foo.component.css',
377+
'/projects/bar/src/app/foo/foo.component.html',
378+
'/projects/bar/src/app/foo/foo.component.ts',
379+
]),
380+
);
381+
expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.spec.ts');
382+
});
368383
});

packages/schematics/angular/directive/index_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,13 @@ describe('Directive Schematic', () => {
174174
.toPromise();
175175
expect(appTree.files).toContain('/projects/bar/custom/app/foo.directive.ts');
176176
});
177+
178+
it('should respect skipTests flag', async () => {
179+
const options = { ...defaultOptions, skipTests: true };
180+
181+
const tree = await schematicRunner.runSchematicAsync('directive', options, appTree).toPromise();
182+
const files = tree.files;
183+
expect(files).toContain('/projects/bar/src/app/foo.directive.ts');
184+
expect(files).not.toContain('/projects/bar/src/app/foo.directive.spec.ts');
185+
});
177186
});

packages/schematics/angular/pipe/index_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,13 @@ describe('Pipe Schematic', () => {
138138
appTree = await schematicRunner.runSchematicAsync('pipe', defaultOptions, appTree).toPromise();
139139
expect(appTree.files).toContain('/projects/bar/custom/app/foo.pipe.ts');
140140
});
141+
142+
it('should respect the skipTests flag', async () => {
143+
const options = { ...defaultOptions, skipTests: true };
144+
145+
const tree = await schematicRunner.runSchematicAsync('pipe', options, appTree).toPromise();
146+
const files = tree.files;
147+
expect(files).not.toContain('/projects/bar/src/app/foo.pipe.spec.ts');
148+
expect(files).toContain('/projects/bar/src/app/foo.pipe.ts');
149+
});
141150
});

0 commit comments

Comments
 (0)