Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
work on #52 - minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Grupp committed Feb 16, 2015
1 parent ba88673 commit 1886132
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 52 deletions.
2 changes: 1 addition & 1 deletion app/sources/sample-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
return JSON.parse(JSON.stringify(this.standard));
},

getAppNameOption: function () {
getForAppNameOption: function () {
var standard = this.getStandard();
delete standard.appName;
delete standard.appModule;
Expand Down
2 changes: 1 addition & 1 deletion controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var MGenerator = yeoman.generators.NamedBase.extend({

initializing: function () {
this.argument('module', { type: String, required: false });
this.moduleName = utils.checkModule(this.module);
this.moduleName = utils.checkModule(this.module);
this.moduleFolder = utils.moduleFolder(this.moduleName);

this.log('You called the m:controller subgenerator.');
Expand Down
41 changes: 1 addition & 40 deletions test/test-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,10 @@ describe('m', function () {
['config.xml', '<name>' + answers.appName + '</name>']
]);
});

// FIXME: cannot test because .yo-rc.json is not available. why?
// describe('m:controller <lowercasename>', function () {
// var controllerName = 'yeah';
// before(function (done) {
// helpers.run(path.join(__dirname, '../controller'))
// .withArguments([controllerName])
// .on('end', done);
// });

// it('generates a new controller with proper content', function () {
// assert.file([
// 'app/scripts/controllers/yeah-ctrl.js'
// ]);
// assert.fileContent([
// [
// 'app/scripts/controllers/yeah-ctrl.js',
// 'angular.module(\'' + answers.appModule + '\')'
// ],
// [
// 'app/scripts/controllers/yeah-ctrl.js',
// '.controller(\'YeahCtrl\', function')
// ]
// ]);
// });
// });
});

describe('m with option --app-name', function () {
var answers = sampleAnswers.getAppNameOption();
var answers = sampleAnswers.getForAppNameOption();

before(function (done) {
helpers.run(path.join(__dirname, '../app'))
Expand All @@ -151,17 +125,4 @@ describe('m', function () {
]);
});
});

// describe('m --skip-prompts', function () {
// before(function (done) {
// helpers.run(path.join(__dirname, '../app'))
// .withGenerators([ // configure path to subgenerators
// path.join(__dirname, '../controller'),
// path.join(__dirname, '../template'),
// path.join(__dirname, '../service')
// ])
// .withOptions({ 'skip-prompts': true}) // execute with options
// .on('end', done);
// });
// });
});
6 changes: 3 additions & 3 deletions test/test-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ var strings = require('../utils/strings.js');

describe('strings', function () {

it('#decapitalize()', function () {
it('.decapitalize()', function () {
assert.textEqual(strings.decapitalize('Asdf'), 'asdf');
assert.textEqual(strings.decapitalize('asdf'), 'asdf');
assert.textEqual(strings.decapitalize('MyNewApp'), 'myNewApp');
});

it('#textToCamel()', function () {
it('.textToCamel()', function () {
// leave camel case
assert.textEqual(strings.textToCamel('myNewApp'), 'myNewApp');
// spaces and capitalization
Expand All @@ -28,7 +28,7 @@ describe('strings', function () {
assert.textEqual(strings.textToCamel('M1y-N2EW 3PP'), 'm1yN2ew3pp');
});

it('#camelToSnake()', function () {
it('.camelToSnake()', function () {
assert.textEqual(strings.camelToSnake('oneTwoThree'), 'one-two-three');
assert.textEqual(strings.camelToSnake('OneTwoThree'), 'one-two-three');
// with dot
Expand Down
14 changes: 7 additions & 7 deletions test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ var config = require('../utils/config.js');

describe('utils', function () {

it('#checkModule()', function () {
it('.checkModule()', function () {
assert.textEqual(utils.checkModule(''), config.DEFAULT_MODULE);
assert.textEqual(utils.checkModule(undefined), config.DEFAULT_MODULE);
assert.textEqual(utils.checkModule('myModule'), 'myModule');
});

it('#moduleName()', function () {
it('.moduleName()', function () {
assert.textEqual(utils.moduleName(' a f dd'), 'aFDd');
assert.textEqual(utils.moduleName('This is my New App P24'), 'thisIsMyNewAppP24');
assert.textEqual(utils.moduleName('Yea -24 !BC$f'), 'yea24Bcf');
});

it('#moduleFolder()', function () {
it('.moduleFolder()', function () {
assert.textEqual(utils.moduleFolder('thisIsMyApp'), 'this-is-my-app');
assert.textEqual(utils.moduleFolder('another2App24'), 'another2-app24');
});

it('#controllerName()', function () {
it('.controllerName()', function () {
assert.textEqual(utils.controllerName('lower'), 'LowerCtrl');
assert.textEqual(utils.controllerName('Upper'), 'UpperCtrl');
assert.textEqual(utils.controllerName('lowerCamel'), 'LowerCamelCtrl');
Expand All @@ -35,20 +35,20 @@ describe('utils', function () {
assert.textEqual(utils.controllerName('UpperCamelController'), 'UpperCamelCtrl');
});

it('#serviceName()', function () {
it('.serviceName()', function () {
assert.textEqual(utils.serviceName('my'), 'My');
assert.textEqual(utils.serviceName('myService'), 'MyService');
assert.textEqual(utils.serviceName('MyService'), 'MyService');
});

it('#fileName()', function () {
it('.fileName()', function () {
assert.textEqual(utils.fileName('lower'), 'lower');
assert.textEqual(utils.fileName('Upper'), 'upper');
assert.textEqual(utils.fileName('thisMyFilename'), 'this-my-filename');
assert.textEqual(utils.fileName('someAp3pName234'), 'some-ap3p-name234');
});

it('#barColor()', function () {
it('.barColor()', function () {
var TEST_COUNT = 10000;
var MAX_DEVIATION_FACTOR = 0.5;
var results = {};
Expand Down

0 comments on commit 1886132

Please sign in to comment.