Skip to content

chore: fix all linting issues with generated app #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
import {
async,
beforeEach,
beforeEachProviders,
describe,
ddescribe,
expect,
iit,
it,
inject
inject,
} from '@angular/core/testing';
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';

describe('Component: <%= classifiedModuleName %>', () => {
let builder: TestComponentBuilder;

beforeEachProviders(() => [<%= classifiedModuleName %>Component]);

it('should create the component', inject([<%= classifiedModuleName %>Component], (component: <%= classifiedModuleName %>Component) => {
expect(component).toBeTruthy();
}));
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
builder = tcb;
}));

it('should inject the component', inject([<%= classifiedModuleName %>Component],
(component: <%= classifiedModuleName %>Component) => {
expect(component).toBeTruthy();
}));

it('should create the component', inject([], () => {
return builder.createAsync(<%= classifiedModuleName %>ComponentTestController)
.then((fixture: ComponentFixture<any>) => {
let query = fixture.debugElement.query(By.directive(<%= classifiedModuleName %>Component));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
});
}));
});

@Component({
selector: 'test',
template: `
<<%= selector %>></<%= selector %>>
`,
directives: [<%= classifiedModuleName %>Component]
})
class <%= classifiedModuleName %>ComponentTestController {
}

2 changes: 1 addition & 1 deletion addon/ng2/blueprints/directive/files/__path__/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>.directive';
export {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>.directive';
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import {
async,
beforeEachProviders,
describe,
ddescribe,
expect,
iit,
it,
inject
} from '@angular/core/testing';
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
import { <%= jsComponentName %>AppComponent } from '../app/<%= htmlComponentName %>.component';

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

describe('App: <%= jsComponentName %>', () => {
it('should create the app', inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
it('should create the app',
inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
expect(app).toBeTruthy();
}));

it('should have as title \'<%= htmlComponentName %> works!\'', inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
it('should have as title \'<%= htmlComponentName %> works!\'',
inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => {
expect(app.title).toEqual('<%= htmlComponentName %> works!');
}));
});
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import {
it,
iit,
describe,
ddescribe,
expect,
inject,
beforeEachProviders
} from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { provide } from '@angular/core';
import { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';

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

it('should transform the input', inject([<%= classifiedModuleName %>], (pipe:<%= classifiedModuleName %>) => {
it('should transform the input', inject([<%= classifiedModuleName %>], (pipe: <%= classifiedModuleName %>) => {
expect(pipe.transform(true)).toBe(null);
}));
});
2 changes: 1 addition & 1 deletion addon/ng2/blueprints/pipe/files/__path__/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';
export { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.pipe';
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import {
async,
beforeEachProviders,
it,
iit,
describe,
ddescribe,
expect,
inject
} from '@angular/core/testing';
import { provide } from '@angular/core';
import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service';

describe('<%= classifiedModuleName %> Service', () => {

beforeEachProviders(() => [<%= classifiedModuleName %>Service]);

it('should ...', inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => {

it('should ...',
inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => {
expect(service).toBeTruthy();
}));

});
2 changes: 1 addition & 1 deletion addon/ng2/blueprints/service/files/__path__/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';
export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';
5 changes: 3 additions & 2 deletions addon/ng2/tasks/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ module.exports = Task.extend({
run: function () {
var ui = this.ui;

return new Promise(function(resolve) {
return new Promise(function(resolve, reject) {
exec('npm run lint', (err, stdout) => {
ui.writeLine(stdout);
if (err) {
ui.writeLine(chalk.red('Lint errors found in the listed files.'));
reject();
} else {
ui.writeLine(chalk.green('All files pass linting.'));
resolve();
}
resolve();
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ module.exports = function(options) {
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');

return cli(options);
}
};
10 changes: 10 additions & 0 deletions tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ describe('Basic end-to-end Workflow', function () {
});
});

it('lints', () => {
this.timeout(420000);

return ng(['lint']).then(() => {
})
.catch(err => {
throw new Error('Linting failed: ' + err);
});
});

it('Perform `ng test` after initial build', function () {
this.timeout(420000);

Expand Down