Skip to content

Commit 8741403

Browse files
committed
fix(tests): add test to verify noImplicityAny builds work
Resolved noImplicitAny issues in blueprints Updated expect for ng build verifications Fixes angular#107
1 parent 877c4f6 commit 8741403

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

addon/ng2/blueprints/component-test/files/src/app/components/__name__/__name__.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>';
1515

1616
describe('<%= classifiedModuleName %> Component', () => {
1717

18-
beforeEachProviders(() => []);
18+
beforeEachProviders((): any[] => []);
1919

2020

2121
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {

addon/ng2/blueprints/directive/files/src/app/directives/__name__/__name__.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import {<%= classifiedModuleName %>} from './<%= dasherizedModuleName %>';
1515

1616
@Component({
1717
selector: 'test-component',
18-
template: `<div <%= dasherizedModuleName %></div>`
18+
template: `<div <%= dasherizedModuleName %>></div>`
1919
})
2020
class TestComponent {}
2121

2222
describe('<%= classifiedModuleName %> Directive', () => {
2323

24-
beforeEachProviders(() => []);
24+
beforeEachProviders((): any[] => []);
2525

2626

2727
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {

addon/ng2/blueprints/ng2/files/src/app/__name__.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
1414
])
1515
export class <%= jsComponentName %>App {
1616
defaultMeaning: number = 42;
17-
17+
1818
meaningOfLife(meaning?: number) {
1919
return `The meaning of life is ${meaning || this.defaultMeaning}`;
2020
}

addon/ng2/blueprints/pipe/files/src/app/pipes/__name__/__name__.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Pipe, PipeTransform} from 'angular2/core';
66
})
77
export class <%= classifiedModuleName %> implements PipeTransform {
88

9-
transform(value, args?) {
9+
transform(value: any, args?: any): any {
1010
return null;
1111
}
1212

tests/e2e/e2e_workflow.spec.js

+32-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Basic end-to-end Workflow', function () {
6363
'build',
6464
'--silent'
6565
]).then(function() {
66-
expect(fs.existsSync(path.join(process.cwd(), 'dist')));
66+
expect(fs.existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
6767
});
6868
});
6969

@@ -174,8 +174,37 @@ describe('Basic end-to-end Workflow', function () {
174174
expect(result.exitCode).to.be.equal(0);
175175

176176
// Clean `tmp` folder
177-
process.chdir(path.resolve(root, '..'));
178-
sh.rm('-rf', './tmp'); // tmp.teardown takes too long
177+
// process.chdir(path.resolve(root, '..'));
178+
// sh.rm('-rf', './tmp'); // tmp.teardown takes too long
179+
});
180+
});
181+
182+
it('Turn on `noImplicitAny` in tsconfig.json and rebuild', function (done) {
183+
this.timeout(420000);
184+
185+
var configFilePath = path.join(process.cwd(), 'src', 'tsconfig.json');
186+
fs.readFile(configFilePath, 'utf8', function(err, data){
187+
188+
var config = JSON.parse(data);
189+
config.compilerOptions.noImplicitAny = true;
190+
191+
fs.writeFile(configFilePath, JSON.stringify(config), function(){
192+
//clear the dist folder
193+
sh.rm('-rf', path.join(process.cwd(), 'dist'));
194+
195+
return ng([
196+
'build',
197+
'--silent'
198+
]).then(function() {
199+
expect(fs.existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
200+
})
201+
.finally(function(){
202+
// Clean `tmp` folder
203+
process.chdir(path.resolve(root, '..'));
204+
sh.rm('-rf', './tmp'); // tmp.teardown takes too long
205+
done();
206+
});
207+
});
179208
});
180209
});
181210

0 commit comments

Comments
 (0)