Skip to content

Commit 2c1b78f

Browse files
alan-agius4vikerman
authored andcommitted
style: remove redundant console.log
1 parent 01930d6 commit 2c1b78f

File tree

1 file changed

+69
-100
lines changed

1 file changed

+69
-100
lines changed

packages/schematics/angular/component/index_spec.ts

Lines changed: 69 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('Component Schematic', () => {
3131
project: 'bar',
3232
};
3333

34-
3534
const workspaceOptions: WorkspaceOptions = {
3635
name: 'workspace',
3736
newProjectRoot: 'projects',
@@ -50,21 +49,23 @@ describe('Component Schematic', () => {
5049
let appTree: UnitTestTree;
5150
beforeEach(async () => {
5251
appTree = schematicRunner.runSchematic('workspace', workspaceOptions);
53-
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree)
52+
appTree = await schematicRunner
53+
.runSchematicAsync('application', appOptions, appTree)
5454
.toPromise();
5555
});
5656

5757
it('should create a component', async () => {
5858
const options = { ...defaultOptions };
59-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
60-
.toPromise();
59+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
6160
const files = tree.files;
62-
expect(files).toEqual(jasmine.arrayContaining([
63-
'/projects/bar/src/app/foo/foo.component.css',
64-
'/projects/bar/src/app/foo/foo.component.html',
65-
'/projects/bar/src/app/foo/foo.component.spec.ts',
66-
'/projects/bar/src/app/foo/foo.component.ts',
67-
]));
61+
expect(files).toEqual(
62+
jasmine.arrayContaining([
63+
'/projects/bar/src/app/foo/foo.component.css',
64+
'/projects/bar/src/app/foo/foo.component.html',
65+
'/projects/bar/src/app/foo/foo.component.spec.ts',
66+
'/projects/bar/src/app/foo/foo.component.ts',
67+
]),
68+
);
6869
const moduleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
6970
expect(moduleContent).toMatch(/import.*Foo.*from '.\/foo\/foo.component'/);
7071
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
@@ -73,95 +74,91 @@ describe('Component Schematic', () => {
7374
it('should set change detection to OnPush', async () => {
7475
const options = { ...defaultOptions, changeDetection: 'OnPush' };
7576

76-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
77-
.toPromise();
77+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
7878
const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
7979
expect(tsContent).toMatch(/changeDetection: ChangeDetectionStrategy.OnPush/);
8080
});
8181

8282
it('should not set view encapsulation', async () => {
8383
const options = { ...defaultOptions };
8484

85-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
86-
.toPromise();
85+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
8786
const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
8887
expect(tsContent).not.toMatch(/encapsulation: ViewEncapsulation/);
8988
});
9089

9190
it('should set view encapsulation to Emulated', async () => {
9291
const options = { ...defaultOptions, viewEncapsulation: 'Emulated' };
9392

94-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
95-
.toPromise();
93+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
9694
const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
9795
expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.Emulated/);
9896
});
9997

10098
it('should set view encapsulation to None', async () => {
10199
const options = { ...defaultOptions, viewEncapsulation: 'None' };
102100

103-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
104-
.toPromise();
101+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
105102
const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
106103
expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.None/);
107104
});
108105

109106
it('should create a flat component', async () => {
110107
const options = { ...defaultOptions, flat: true };
111108

112-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
113-
.toPromise();
109+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
114110
const files = tree.files;
115-
expect(files).toEqual(jasmine.arrayContaining([
116-
'/projects/bar/src/app/foo.component.css',
117-
'/projects/bar/src/app/foo.component.html',
118-
'/projects/bar/src/app/foo.component.spec.ts',
119-
'/projects/bar/src/app/foo.component.ts',
120-
]));
111+
expect(files).toEqual(
112+
jasmine.arrayContaining([
113+
'/projects/bar/src/app/foo.component.css',
114+
'/projects/bar/src/app/foo.component.html',
115+
'/projects/bar/src/app/foo.component.spec.ts',
116+
'/projects/bar/src/app/foo.component.ts',
117+
]),
118+
);
121119
});
122120

123121
it('should find the closest module', async () => {
124122
const options = { ...defaultOptions };
125123
const fooModule = '/projects/bar/src/app/foo/foo.module.ts';
126-
appTree.create(fooModule, `
124+
appTree.create(
125+
fooModule,
126+
`
127127
import { NgModule } from '@angular/core';
128128
129129
@NgModule({
130130
imports: [],
131131
declarations: []
132132
})
133133
export class FooModule { }
134-
`);
134+
`,
135+
);
135136

136-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
137-
.toPromise();
137+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
138138
const fooModuleContent = tree.readContent(fooModule);
139139
expect(fooModuleContent).toMatch(/import { FooComponent } from '.\/foo.component'/);
140140
});
141141

142142
it('should export the component', async () => {
143143
const options = { ...defaultOptions, export: true };
144144

145-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
146-
.toPromise();
145+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
147146
const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
148147
expect(appModuleContent).toMatch(/exports: \[FooComponent\]/);
149148
});
150149

151150
it('should set the entry component', async () => {
152151
const options = { ...defaultOptions, entryComponent: true };
153152

154-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
155-
.toPromise();
153+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
156154
const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
157155
expect(appModuleContent).toMatch(/entryComponents: \[FooComponent\]/);
158156
});
159157

160158
it('should import into a specified module', async () => {
161159
const options = { ...defaultOptions, module: 'app.module.ts' };
162160

163-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
164-
.toPromise();
161+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
165162
const appModule = tree.readContent('/projects/bar/src/app/app.module.ts');
166163

167164
expect(appModule).toMatch(/import { FooComponent } from '.\/foo\/foo.component'/);
@@ -182,76 +179,60 @@ describe('Component Schematic', () => {
182179
const pathOption = 'projects/bar/src/app/SOME/UPPER/DIR';
183180
const options = { ...defaultOptions, path: pathOption };
184181

185-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
186-
.toPromise();
182+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
187183
let files = tree.files;
188184
let root = `/${pathOption}/foo/foo.component`;
189-
expect(files).toEqual(jasmine.arrayContaining([
190-
`${root}.css`,
191-
`${root}.html`,
192-
`${root}.spec.ts`,
193-
`${root}.ts`,
194-
]));
185+
expect(files).toEqual(
186+
jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`]),
187+
);
195188

196189
const options2 = { ...options, name: 'BAR' };
197-
const tree2 = await schematicRunner.runSchematicAsync('component', options2, tree)
198-
.toPromise();
190+
const tree2 = await schematicRunner.runSchematicAsync('component', options2, tree).toPromise();
199191
files = tree2.files;
200192
root = `/${pathOption}/bar/bar.component`;
201-
expect(files).toEqual(jasmine.arrayContaining([
202-
`${root}.css`,
203-
`${root}.html`,
204-
`${root}.spec.ts`,
205-
`${root}.ts`,
206-
]));
193+
expect(files).toEqual(
194+
jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`]),
195+
);
207196
});
208197

209198
it('should create a component in a sub-directory', async () => {
210199
const options = { ...defaultOptions, path: 'projects/bar/src/app/a/b/c' };
211200

212-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
213-
.toPromise();
201+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
214202
const files = tree.files;
215203
const root = `/${options.path}/foo/foo.component`;
216-
expect(files).toEqual(jasmine.arrayContaining([
217-
`${root}.css`,
218-
`${root}.html`,
219-
`${root}.spec.ts`,
220-
`${root}.ts`,
221-
]));
204+
expect(files).toEqual(
205+
jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`]),
206+
);
222207
});
223208

224209
it('should use the prefix', async () => {
225210
const options = { ...defaultOptions, prefix: 'pre' };
226211

227-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
228-
.toPromise();
212+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
229213
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
230214
expect(content).toMatch(/selector: 'pre-foo'/);
231215
});
232216

233217
it('should use the default project prefix if none is passed', async () => {
234218
const options = { ...defaultOptions, prefix: undefined };
235219

236-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
237-
.toPromise();
220+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
238221
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
239222
expect(content).toMatch(/selector: 'app-foo'/);
240223
});
241224

242225
it('should use the supplied prefix if it is ""', async () => {
243226
const options = { ...defaultOptions, prefix: '' };
244227

245-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
246-
.toPromise();
228+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
247229
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
248230
expect(content).toMatch(/selector: 'foo'/);
249231
});
250232

251233
it('should respect the inlineTemplate option', async () => {
252234
const options = { ...defaultOptions, inlineTemplate: true };
253-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
254-
.toPromise();
235+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
255236
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
256237
expect(content).toMatch(/template: /);
257238
expect(content).not.toMatch(/templateUrl: /);
@@ -260,8 +241,7 @@ describe('Component Schematic', () => {
260241

261242
it('should respect the inlineStyle option', async () => {
262243
const options = { ...defaultOptions, inlineStyle: true };
263-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
264-
.toPromise();
244+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
265245
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
266246
expect(content).toMatch(/styles: \[/);
267247
expect(content).not.toMatch(/styleUrls: /);
@@ -270,8 +250,7 @@ describe('Component Schematic', () => {
270250

271251
it('should respect the style option', async () => {
272252
const options = { ...defaultOptions, style: Style.Sass };
273-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
274-
.toPromise();
253+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
275254
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
276255
expect(content).toMatch(/styleUrls: \['.\/foo.component.sass/);
277256
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.sass');
@@ -283,55 +262,49 @@ describe('Component Schematic', () => {
283262
const routingModulePath = `/projects/bar/src/app/${routingFileName}`;
284263
const newTree = createAppModule(appTree, routingModulePath);
285264
const options = { ...defaultOptions, module: routingFileName };
286-
const tree = await schematicRunner.runSchematicAsync('component', options, newTree)
287-
.toPromise();
265+
const tree = await schematicRunner.runSchematicAsync('component', options, newTree).toPromise();
288266
const content = tree.readContent(routingModulePath);
289267
expect(content).toMatch(/import { FooComponent } from '.\/foo\/foo.component/);
290268
});
291269

292270
it('should handle a path in the name option', async () => {
293271
const options = { ...defaultOptions, name: 'dir/test-component' };
294272

295-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
296-
.toPromise();
273+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
297274
const content = tree.readContent('/projects/bar/src/app/app.module.ts');
298275
expect(content).toMatch(
299276
// tslint:disable-next-line:max-line-length
300-
/import { TestComponentComponent } from '\.\/dir\/test-component\/test-component.component'/);
277+
/import { TestComponentComponent } from '\.\/dir\/test-component\/test-component.component'/,
278+
);
301279
});
302280

303281
it('should handle a path in the name and module options', async () => {
304-
appTree = await schematicRunner.runSchematicAsync(
305-
'module',
306-
{ name: 'admin/module', project: 'bar' },
307-
appTree,
308-
).toPromise();
282+
appTree = await schematicRunner
283+
.runSchematicAsync('module', { name: 'admin/module', project: 'bar' }, appTree)
284+
.toPromise();
309285

310286
const options = { ...defaultOptions, name: 'other/test-component', module: 'admin/module' };
311-
appTree = await schematicRunner.runSchematicAsync('component', options, appTree)
312-
.toPromise();
287+
appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
313288

314289
const content = appTree.readContent('/projects/bar/src/app/admin/module/module.module.ts');
315290
expect(content).toMatch(
316291
// tslint:disable-next-line:max-line-length
317-
/import { TestComponentComponent } from '..\/..\/other\/test-component\/test-component.component'/);
292+
/import { TestComponentComponent } from '..\/..\/other\/test-component\/test-component.component'/,
293+
);
318294
});
319295

320296
it('should create the right selector with a path in the name', async () => {
321297
const options = { ...defaultOptions, name: 'sub/test' };
322-
appTree = await schematicRunner.runSchematicAsync('component', options, appTree)
323-
.toPromise();
298+
appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
324299
const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
325300
expect(content).toMatch(/selector: 'app-test'/);
326301
});
327302

328303
it('should respect the skipSelector option', async () => {
329304
const options = { ...defaultOptions, name: 'sub/test', skipSelector: true };
330-
appTree = await schematicRunner.runSchematicAsync('component', options, appTree)
331-
.toPromise();
305+
appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
332306
const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
333307
expect(content).not.toMatch(/selector: 'app-test'/);
334-
console.log(content);
335308
});
336309

337310
it('should respect the sourceRoot value', async () => {
@@ -346,42 +319,38 @@ describe('Component Schematic', () => {
346319

347320
// move the module
348321
appTree.rename('/projects/bar/src/app/app.module.ts', '/projects/bar/custom/app/app.module.ts');
349-
appTree = await schematicRunner.runSchematicAsync('component', defaultOptions, appTree)
322+
appTree = await schematicRunner
323+
.runSchematicAsync('component', defaultOptions, appTree)
350324
.toPromise();
351325
expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.component.ts');
352326
});
353327

354328
// testing deprecating options don't cause conflicts
355329
it('should respect the deprecated styleext (scss) option', async () => {
356330
const options = { ...defaultOptions, style: undefined, styleext: 'scss' };
357-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
358-
.toPromise();
331+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
359332
const files = tree.files;
360333
expect(files).toContain('/projects/bar/src/app/foo/foo.component.scss');
361334
});
362335

363336
it('should respect the deprecated styleext (css) option', async () => {
364337
const options = { ...defaultOptions, style: undefined, styleext: 'css' };
365-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
366-
.toPromise();
338+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
367339
const files = tree.files;
368340
expect(files).toContain('/projects/bar/src/app/foo/foo.component.css');
369341
});
370342

371343
it('should respect the deprecated spec option when false', async () => {
372344
const options = { ...defaultOptions, skipTests: undefined, spec: false };
373-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
374-
.toPromise();
345+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
375346
const files = tree.files;
376347
expect(files).not.toContain('/projects/bar/src/app/foo/foo.component.spec.ts');
377348
});
378349

379350
it('should respect the deprecated spec option when true', async () => {
380351
const options = { ...defaultOptions, skipTests: false, spec: true };
381-
const tree = await schematicRunner.runSchematicAsync('component', options, appTree)
382-
.toPromise();
352+
const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
383353
const files = tree.files;
384354
expect(files).toContain('/projects/bar/src/app/foo/foo.component.spec.ts');
385355
});
386-
387356
});

0 commit comments

Comments
 (0)