11import Mixin from '@ember/object/mixin' ;
2+ import { camelize } from '@ember/string' ;
23
34export default Mixin . create ( {
45 ensureTestHelperExists ( ) {
56 this . _ensureExists ( 'tests/test-helper.js' , 'test-helper' ) ;
67 } ,
78
8- ensureTestStartAppHelperExists ( ) {
9- this . _ensureExists ( 'tests/helpers/start-app.js' , 'test-start-app' ) ;
10- } ,
11-
12- ensureTestDestroyAppHelperExists ( ) {
13- this . _ensureExists ( 'tests/helpers/destroy-app.js' , 'test-destroy-app' ) ;
14- } ,
15-
16- ensureTestModuleForAcceptanceHelperExists ( ) {
17- this . _ensureExists ( 'tests/helpers/module-for-acceptance.js' , 'test-module-for-acceptance' ) ;
18- } ,
19-
209 _ensureExists ( filePath , blueprint ) {
2110 if ( ! this . hasPath ( filePath ) ) {
2211 const fileProperties = this . emberCli . buildProperties ( blueprint ) ;
@@ -30,7 +19,9 @@ export default Mixin.create({
3019 const splitFilePath = filePath . split ( '/' ) ;
3120 const file = splitFilePath [ splitFilePath . length - 1 ] ;
3221 const name = file . replace ( '-test.js' , '' ) ;
33- return { filePath, name } ;
22+ let camelizedName = camelize ( name ) ;
23+ camelizedName = setCharAt ( camelizedName , 0 , name [ 0 ] . toUpperCase ( ) ) ;
24+ return { filePath, name, camelizedName } ;
3425 } ,
3526
3627 ensureTestingEnabled ( ) {
@@ -44,7 +35,11 @@ export default Mixin.create({
4435
4536 const fileProperties = this . emberCli . buildProperties ( blueprint , {
4637 dasherizedModuleName : name ,
47- friendlyTestDescription : 'TODO: put something here'
38+ moduleName : name ,
39+ friendlyTestDescription : 'TODO: put something here' ,
40+ routePathName : name ,
41+ controllerPathName : name ,
42+ servicePathName : name ,
4843 } ) ;
4944
5045 if ( this . isPathInvalid ( blueprint , filePath ) ) {
@@ -56,12 +51,19 @@ export default Mixin.create({
5651 createIntegrationTestFile ( type ) {
5752 this . ensureTestHelperExists ( ) ;
5853 const blueprint = type + '-test' ;
59- const { filePath, name } = this . calculateFileVarsForTests ( blueprint ) ;
54+ const { filePath, camelizedName } = this . calculateFileVarsForTests ( blueprint ) ;
55+
56+ let openComponent = descriptor => `<${ descriptor } >` ;
57+ let closeComponent = descriptor => `</${ descriptor } >` ;
58+ let selfCloseComponent = descriptor => `<${ descriptor } />` ;
6059
6160 const fileProperties = this . emberCli . buildProperties ( blueprint , {
6261 testType : 'integration' ,
63- componentPathName : name ,
64- friendlyTestDescription : 'TODO: put something here'
62+ componentName : camelizedName ,
63+ friendlyTestDescription : 'TODO: put something here' ,
64+ openComponent,
65+ closeComponent,
66+ selfCloseComponent
6567 } ) ;
6668
6769 if ( this . isPathInvalid ( blueprint , filePath ) ) {
@@ -72,9 +74,6 @@ export default Mixin.create({
7274
7375 createAcceptanceTestFile ( ) {
7476 this . ensureTestHelperExists ( ) ;
75- this . ensureTestStartAppHelperExists ( ) ;
76- this . ensureTestDestroyAppHelperExists ( ) ;
77- this . ensureTestModuleForAcceptanceHelperExists ( ) ;
7877 const blueprint = 'acceptance-test' ;
7978 const { filePath, name } = this . calculateFileVarsForTests ( blueprint ) ;
8079
@@ -90,3 +89,8 @@ export default Mixin.create({
9089 this . createFile ( filePath , fileProperties ) ;
9190 }
9291} ) ;
92+
93+ function setCharAt ( str , index , char ) {
94+ if ( index > str . length - 1 ) return str ;
95+ return str . substr ( 0 , index ) + char + str . substr ( index + 1 ) ;
96+ }
0 commit comments