Skip to content

Commit a9f14a7

Browse files
committed
chore: fix all linting issues with generated app (angular#611)
1 parent 44e300b commit a9f14a7

File tree

10 files changed

+59
-33
lines changed

10 files changed

+59
-33
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
import {
2-
async,
2+
beforeEach,
33
beforeEachProviders,
44
describe,
5-
ddescribe,
65
expect,
7-
iit,
86
it,
9-
inject
7+
inject,
108
} from '@angular/core/testing';
119
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
10+
import { Component } from '@angular/core';
11+
import { By } from '@angular/platform-browser';
1212
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';
1313

1414
describe('Component: <%= classifiedModuleName %>', () => {
15+
let builder: TestComponentBuilder;
16+
1517
beforeEachProviders(() => [<%= classifiedModuleName %>Component]);
16-
17-
it('should create the component', inject([<%= classifiedModuleName %>Component], (component: <%= classifiedModuleName %>Component) => {
18-
expect(component).toBeTruthy();
19-
}));
18+
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
19+
builder = tcb;
20+
}));
21+
22+
it('should inject the component', inject([<%= classifiedModuleName %>Component],
23+
(component: <%= classifiedModuleName %>Component) => {
24+
expect(component).toBeTruthy();
25+
}));
26+
27+
it('should create the component', inject([], () => {
28+
return builder.createAsync(<%= classifiedModuleName %>ComponentTestController)
29+
.then((fixture: ComponentFixture<any>) => {
30+
let query = fixture.debugElement.query(By.directive(<%= classifiedModuleName %>Component));
31+
expect(query).toBeTruthy();
32+
expect(query.componentInstance).toBeTruthy();
33+
});
34+
}));
2035
});
36+
37+
@Component({
38+
selector: 'test',
39+
template: `
40+
<<%= selector %>></<%= selector %>>
41+
`,
42+
directives: [<%= classifiedModuleName %>Component]
43+
})
44+
class <%= classifiedModuleName %>ComponentTestController {
45+
}
46+
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>.directive';
1+
export {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>.directive';
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import {
2-
async,
32
beforeEachProviders,
43
describe,
5-
ddescribe,
64
expect,
7-
iit,
85
it,
96
inject
107
} from '@angular/core/testing';
11-
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
128
import { <%= jsComponentName %>AppComponent } from '../app/<%= htmlComponentName %>.component';
139

1410
beforeEachProviders(() => [<%= jsComponentName %>AppComponent]);
1511

1612
describe('App: <%= jsComponentName %>', () => {
17-
it('should create the app', inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
13+
it('should create the app',
14+
inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
1815
expect(app).toBeTruthy();
1916
}));
2017

21-
it('should have as title \'<%= htmlComponentName %> works!\'', inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
18+
it('should have as title \'<%= htmlComponentName %> works!\'',
19+
inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
2220
expect(app.title).toEqual('<%= htmlComponentName %> works!');
2321
}));
2422
});
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import {
22
it,
3-
iit,
43
describe,
5-
ddescribe,
64
expect,
75
inject,
86
beforeEachProviders
97
} from '@angular/core/testing';
10-
import { TestComponentBuilder } from '@angular/compiler/testing';
11-
import { provide } from '@angular/core';
128
import { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';
139

1410
describe('<%= classifiedModuleName %> Pipe', () => {
1511
beforeEachProviders(() => [<%= classifiedModuleName%>]);
1612

17-
it('should transform the input', inject([<%= classifiedModuleName %>], (pipe:<%= classifiedModuleName %>) => {
13+
it('should transform the input', inject([<%= classifiedModuleName %>], (pipe: <%= classifiedModuleName %>) => {
1814
expect(pipe.transform(true)).toBe(null);
1915
}));
2016
});
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';
1+
export { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import {
2-
async,
32
beforeEachProviders,
43
it,
5-
iit,
64
describe,
7-
ddescribe,
85
expect,
96
inject
107
} from '@angular/core/testing';
11-
import { provide } from '@angular/core';
128
import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service';
139

1410
describe('<%= classifiedModuleName %> Service', () => {
15-
1611
beforeEachProviders(() => [<%= classifiedModuleName %>Service]);
1712

18-
it('should ...', inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => {
19-
13+
it('should ...',
14+
inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => {
15+
expect(service).toBeTruthy();
2016
}));
21-
2217
});
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';
1+
export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';

addon/ng2/tasks/lint.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ module.exports = Task.extend({
77
run: function () {
88
var ui = this.ui;
99

10-
return new Promise(function(resolve) {
10+
return new Promise(function(resolve, reject) {
1111
exec('npm run lint', (err, stdout) => {
1212
ui.writeLine(stdout);
1313
if (err) {
1414
ui.writeLine(chalk.red('Lint errors found in the listed files.'));
15+
reject();
1516
} else {
1617
ui.writeLine(chalk.green('All files pass linting.'));
18+
resolve();
1719
}
18-
resolve();
1920
});
2021
});
2122
}

lib/cli/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ module.exports = function(options) {
100100
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');
101101

102102
return cli(options);
103-
}
103+
};

tests/e2e/e2e_workflow.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ describe('Basic end-to-end Workflow', function () {
8888
});
8989
});
9090

91+
it('lints', () => {
92+
this.timeout(420000);
93+
94+
return ng(['lint']).then(() => {
95+
})
96+
.catch(err => {
97+
throw new Error('Linting failed: ' + err);
98+
});
99+
});
100+
91101
it('Perform `ng test` after initial build', function () {
92102
this.timeout(420000);
93103

0 commit comments

Comments
 (0)