This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work on #198 - module templates: test & implement tabs
- Loading branch information
Showing
6 changed files
with
194 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,14 @@ var MGenerator = yeoman.generators.NamedBase.extend({ | |
name: 'template', | ||
message: 'Choose a starter template', | ||
choices: [ | ||
{ | ||
value: 'tabs', | ||
name: 'tabs', | ||
}, | ||
{ | ||
value: 'sidemenu', | ||
name: 'sidemenu' | ||
}, | ||
{ | ||
value: 'tabs', | ||
name: 'tabs', | ||
}, | ||
{ | ||
value: 'blank', | ||
name: 'blank' | ||
|
@@ -93,8 +93,9 @@ var MGenerator = yeoman.generators.NamedBase.extend({ | |
this.copy('env-prod.json', modulePath + '/constants/env-prod.json'); | ||
} | ||
|
||
// sidemenu | ||
if (this.answers.template === 'sidemenu') { | ||
// both | ||
if (this.answers.template !== 'blank') { | ||
// [email protected] | ||
this.copy('yo.png', modulePath + '/assets/images/[email protected]'); | ||
|
||
// debug | ||
|
@@ -111,15 +112,6 @@ var MGenerator = yeoman.generators.NamedBase.extend({ | |
options: { template: 'debug' } | ||
}); | ||
|
||
// menu | ||
this.composeWith('m:controller', { | ||
arguments: this.menuCtrlName + ' ' + this.moduleName, | ||
}); | ||
this.composeWith('m:template', { | ||
arguments: 'menu ' + this.moduleName, | ||
options: { template: 'menu' } | ||
}); | ||
|
||
// other templates | ||
this.composeWith('m:template', { | ||
arguments: 'list ' + this.moduleName, | ||
|
@@ -130,19 +122,25 @@ var MGenerator = yeoman.generators.NamedBase.extend({ | |
options: { template: 'list-detail' } | ||
}); | ||
} | ||
// tabs | ||
else if (this.answers.template === 'tabs') { | ||
this.copy('yo.png', modulePath + '/assets/images/[email protected]'); | ||
// sidemenu | ||
if (this.answers.template === 'sidemenu') { | ||
// menu | ||
this.composeWith('m:controller', { | ||
arguments: this.menuCtrlName + ' ' + this.moduleName, | ||
}); | ||
this.composeWith('m:template', { | ||
arguments: 'menu ' + this.moduleName, | ||
options: { template: 'menu' } | ||
}); | ||
} | ||
|
||
var options = { | ||
arguments: this.name + ' ' + this.moduleName, | ||
options: { | ||
sample: 'start' | ||
} | ||
}; | ||
this.composeWith('m:template', options); | ||
this.composeWith('m:service', options); | ||
this.composeWith('m:controller', options); | ||
// tabs | ||
if (this.answers.template === 'tabs') { | ||
// tabs | ||
this.composeWith('m:template', { | ||
arguments: 'tabs ' + this.moduleName, | ||
options: { template: 'tabs' } | ||
}); | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<ion-tabs class="tabs-icon-top tabs-assertive"> | ||
|
||
<!-- List Tab --> | ||
<ion-tab title="List" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" | ||
ui-sref="<%= moduleName %>.list"> | ||
<ion-nav-view name="tab-list"></ion-nav-view> | ||
</ion-tab> | ||
|
||
<!-- Debug Tab --> | ||
<ion-tab title="Debug" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" | ||
ui-sref="<%= moduleName %>.debug"> | ||
<ion-nav-view name="tab-debug"></ion-nav-view> | ||
</ion-tab> | ||
|
||
</ion-tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,18 +72,119 @@ describe('m:module', function () { | |
}); | ||
}; | ||
|
||
// var tabsTests = function (moduleName, options) { | ||
// var moduleFolder = utils.moduleFolder(moduleName); | ||
// var modulePath = 'app/' + moduleFolder; | ||
// console.log(options); | ||
|
||
// it('tabs tests', function () { | ||
// assert.file([ | ||
// modulePath + '/assets/images/[email protected]', | ||
|
||
// ]); | ||
// }); | ||
// }; | ||
var tabsTests = function (moduleName, options) { | ||
var moduleFolder = utils.moduleFolder(moduleName); | ||
var modulePath = 'app/' + moduleFolder; | ||
console.log(options); | ||
|
||
it('tabs tests', function () { | ||
assert.file([ | ||
modulePath + '/assets/images/[email protected]', | ||
]); | ||
|
||
var moduleFile = modulePath + '/' + moduleFolder + '.js'; | ||
var serviceFile = modulePath + '/services/' + moduleFolder + '-serv.js'; | ||
var serviceName = utils.serviceName(moduleName); | ||
var debugCtrlFile, debugCtrlName; | ||
var configName; | ||
|
||
// mainModule tests | ||
if (options && options.mainModule) { | ||
debugCtrlFile = modulePath + '/controllers/debug-ctrl.js'; | ||
debugCtrlName = utils.controllerName('Debug'); | ||
configName = utils.configName(); | ||
|
||
// module.js | ||
assert.fileContent(moduleFile, 'otherwise(\'/' + moduleFolder + '/list'); | ||
} | ||
// no mainModule test | ||
else { | ||
debugCtrlFile = modulePath + '/controllers/' + moduleFolder + '-debug-ctrl.js'; | ||
debugCtrlName = utils.controllerName(moduleName + 'Debug'); | ||
configName = utils.configName(moduleName); | ||
|
||
// module.js | ||
assert.noFileContent(moduleFile, 'otherwise(\'/'); | ||
} | ||
|
||
// in any case | ||
assert.fileContent([ | ||
// module.js | ||
[moduleFile, 'abstract: true'], | ||
[moduleFile, 'templateUrl: \'' + moduleFolder + '/templates/tabs.html'], | ||
[moduleFile, '.state(\'' + moduleName + '.list'], | ||
[moduleFile, 'templateUrl: \'' + moduleFolder + '/templates/list.html'], | ||
[moduleFile, '.state(\'' + moduleName + '.listDetail'], | ||
[moduleFile, 'templateUrl: \'' + moduleFolder + '/templates/list-detail.html'], | ||
[moduleFile, '.state(\'' + moduleName + '.debug'], | ||
[moduleFile, 'templateUrl: \'' + moduleFolder + '/templates/debug.html'], | ||
[moduleFile, 'controller: \'' + debugCtrlName + ' as ctrl'], | ||
|
||
// template files | ||
[debugCtrlFile, 'controller(\'' + debugCtrlName], | ||
[debugCtrlFile, serviceName + ', ' + configName], | ||
[debugCtrlFile, 'this.someData = ' + serviceName], | ||
[debugCtrlFile, 'this.ENV = ' + configName], | ||
[debugCtrlFile, 'this.BUILD = ' + configName], | ||
[serviceFile, 'service(\'' + serviceName], | ||
]); | ||
|
||
// templates | ||
assert.fileContent([ | ||
[modulePath + '/templates/debug.html', 'ctrl.someData.binding'], | ||
[modulePath + '/templates/list-detail.html', 'I scaffold apps'], | ||
[modulePath + '/templates/list.html', 'Learn more...'], | ||
[modulePath + '/templates/list.html', moduleName + '.listDetail'], | ||
[modulePath + '/templates/tabs.html', '<ion-tabs'], | ||
[modulePath + '/templates/tabs.html', moduleName + '.list'], | ||
[modulePath + '/templates/tabs.html', moduleName + '.debug'], | ||
]); | ||
}); | ||
}; | ||
|
||
describe('main (main, tabs)', function () { | ||
var options = { | ||
mainModule: true | ||
}; | ||
|
||
before(function (done) { | ||
helpers.run(path.join(__dirname, '../module')) | ||
.withGenerators([ // configure path to subgenerators | ||
path.join(__dirname, '../controller'), | ||
path.join(__dirname, '../template'), | ||
path.join(__dirname, '../service'), | ||
path.join(__dirname, '../constant') | ||
]) | ||
.withArguments('main') | ||
.withPrompts({ template: 'tabs' }) | ||
.withOptions(options) | ||
.on('end', done); | ||
}); | ||
|
||
basicFilesTests('main', options); | ||
mainModuleTests('main'); | ||
tabsTests('main', options); | ||
}); | ||
|
||
describe('myModule (no main, tabs)', function () { | ||
|
||
before(function (done) { | ||
helpers.run(path.join(__dirname, '../module')) | ||
.withGenerators([ // configure path to subgenerators | ||
path.join(__dirname, '../controller'), | ||
path.join(__dirname, '../template'), | ||
path.join(__dirname, '../service'), | ||
path.join(__dirname, '../constant') | ||
]) | ||
.withArguments('myModule') | ||
.withPrompts({ template: 'tabs' }) | ||
.on('end', done); | ||
}); | ||
|
||
basicFilesTests('myModule'); | ||
noMainModuleTests('myModule'); | ||
tabsTests('myModule'); | ||
}); | ||
|
||
var sideMenuTests = function (moduleName, options) { | ||
var moduleFolder = utils.moduleFolder(moduleName); | ||
|