From ea9c80ab414694df7d3597e4b2505b579cc578f1 Mon Sep 17 00:00:00 2001 From: Avi Haiat Date: Wed, 3 Feb 2016 15:01:20 +0200 Subject: [PATCH 1/2] fix(app): Dasherize appname --- generators/app/index.js | 9 ++++---- generators/app/templates/_npmrc | 2 +- .../component/templates/_component.spec.ts | 22 +++++++++++++------ test/mocha/app.spec.js | 4 ++-- test/mocha/component.spec.js | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/generators/app/index.js b/generators/app/index.js index 35eae63..6d13ae8 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -24,7 +24,7 @@ module.exports = generators.Base.extend({ this.mixins.beautifyJson(); this.appname = this.appname || path.basename(process.cwd()); - this.appname = this.mixins.camelize(this.appname); + this.appname = this.mixins.dasherize(this.appname); //******* arguments *********** // To access arguments later use this.argumentName @@ -36,7 +36,7 @@ module.exports = generators.Base.extend({ defaults: this.appname }); - this.appname = this.mixins.camelize(this.appname); + this.appname = this.mixins.dasherize(this.appname); // ***** arguments ******** // ****** options ********* @@ -86,6 +86,7 @@ module.exports = generators.Base.extend({ }]; this.prompt(prompts, function(answers) { this.answers = answers; + this.appname = this.answers.appname ? this.mixins.dasherize(this.answers.appname) : this.mixins.dasherize(this.appname); // To access answers later use this.answers.someAnswer; this.answers.clientFolder = this.mixins.dasherize(this.answers.clientFolder); done(); @@ -135,14 +136,14 @@ module.exports = generators.Base.extend({ this.fs.copyTpl( this.templatePath('_package.json'), this.destinationPath('package.json'), { - appname: this.mixins.dasherize(this.appname), + appname: this.appname, clientFolder: this.answers.clientFolder } ); this.fs.copyTpl( this.templatePath('_README.md'), this.destinationPath('README.md'), { - appname: this.mixins.dasherize(this.appname) + appname: this.appname } ); this.fs.copyTpl( diff --git a/generators/app/templates/_npmrc b/generators/app/templates/_npmrc index b4c7d1d..2eb100a 100644 --- a/generators/app/templates/_npmrc +++ b/generators/app/templates/_npmrc @@ -1 +1 @@ -loglevel=silent \ No newline at end of file +loglevel=error \ No newline at end of file diff --git a/generators/component/templates/_component.spec.ts b/generators/component/templates/_component.spec.ts index e236768..b128b0a 100644 --- a/generators/component/templates/_component.spec.ts +++ b/generators/component/templates/_component.spec.ts @@ -1,7 +1,7 @@ /* beautify ignore:start */ import { it, - //inject, + inject, injectAsync, beforeEachProviders, TestComponentBuilder @@ -10,16 +10,24 @@ import {<%=componentnameClass%>Component} from './<%=componentnameFile%>.compone /* beautify ignore:end */ describe('Component: <%=componentnameClass%>Component', () => { - + let builder; beforeEachProviders(() => []); - it('should be defined', injectAsync([TestComponentBuilder], (tcb) => { - return tcb.createAsync(<%=componentnameClass%>Component) + beforeEach(inject([TestComponentBuilder], (tcb) => { + builder = tcb; + })); + + it('should be defined', (done) => { + return builder + .createAsync(<%=componentnameClass%>Component) .then((fixture) => { fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; - expect(compiled).toBeDefined(); + let cmpInstance = fixture.debugElement.componentInstance; + let element = fixture.debugElement.nativeElement; + expect(cmpInstance).toBeDefined(); + expect(element).toBeDefined(); + done(); }); - })); + }); }); \ No newline at end of file diff --git a/test/mocha/app.spec.js b/test/mocha/app.spec.js index 202ab84..499b879 100644 --- a/test/mocha/app.spec.js +++ b/test/mocha/app.spec.js @@ -61,7 +61,7 @@ describe(generatorShortname + ':app', function() { it('creates a .yo-rc.json file', function() { var content = {}; content[generatorFullname] = { - appname: appname, + appname: 'name-x', clientFolder: clientFolder }; assert.JSONFileContent('.yo-rc.json', content); @@ -86,7 +86,7 @@ describe(generatorShortname + ':app', function() { it('should be transformed to snake case', function() { var content = {}; content[generatorFullname] = { - appname: appname, + appname: 'name-x', clientFolder: 'dummy-folder' }; assert.JSONFileContent('.yo-rc.json', content); diff --git a/test/mocha/component.spec.js b/test/mocha/component.spec.js index 0137a71..208816c 100644 --- a/test/mocha/component.spec.js +++ b/test/mocha/component.spec.js @@ -53,7 +53,7 @@ describe(generatorShortname + ':component', function() { [pathdir + 'my-dummy.component.ts', /export class MyDummyComponent/], [pathdir + 'my-dummy.component.ts', /selector: 'my-dummy'/], [pathdir + 'my-dummy.component.spec.ts', /import {MyDummyComponent} from '\.\/my-dummy.component.ts';/], - [pathdir + 'my-dummy.component.spec.ts', /return tcb.createAsync\(MyDummyComponent\)/], + [pathdir + 'my-dummy.component.spec.ts', /createAsync\(MyDummyComponent\)/], [pathdir + 'my-dummy.component.html', /
myDummy<\/div>/] ]; From 52f54b2747565dcb45c8126e513e676b7d2a5133 Mon Sep 17 00:00:00 2001 From: Avi Haiat Date: Wed, 3 Feb 2016 15:25:00 +0200 Subject: [PATCH 2/2] fix(component): Revert unit test for component --- .../component/templates/_component.spec.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/generators/component/templates/_component.spec.ts b/generators/component/templates/_component.spec.ts index b128b0a..c723a72 100644 --- a/generators/component/templates/_component.spec.ts +++ b/generators/component/templates/_component.spec.ts @@ -1,7 +1,7 @@ /* beautify ignore:start */ import { it, - inject, + //inject, injectAsync, beforeEachProviders, TestComponentBuilder @@ -13,21 +13,15 @@ describe('Component: <%=componentnameClass%>Component', () => { let builder; beforeEachProviders(() => []); - beforeEach(inject([TestComponentBuilder], (tcb) => { - builder = tcb; - })); - - it('should be defined', (done) => { - return builder - .createAsync(<%=componentnameClass%>Component) + it('should be defined', injectAsync([TestComponentBuilder], (tcb) => { + return tcb.createAsync(<%=componentnameClass%>Component) .then((fixture) => { fixture.detectChanges(); - let cmpInstance = fixture.debugElement.componentInstance; let element = fixture.debugElement.nativeElement; + let cmpInstance = fixture.debugElement.componentInstance; expect(cmpInstance).toBeDefined(); expect(element).toBeDefined(); - done(); }); - }); + })); }); \ No newline at end of file