Skip to content

Commit

Permalink
Remove duplication in lib/utilities/test-info
Browse files Browse the repository at this point in the history
  • Loading branch information
quaertym committed May 20, 2015
1 parent b06bb85 commit 69087f8
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions lib/utilities/test-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,34 @@ module.exports = {
@return {String} the humanize string.
*/
humanize: function(str) {
var ret;
var ret;
ret = stringUtils.dasherize(str).replace(/[-]/g,' ');
return ret;
},

/**
@private
@method _friendlyText
@param {String} text Text that will be humanized.
@param {String} testType The type of test (Unit, Acceptance, etc).
@param {String} blueprintType The type of bluprint (Component, Mixin, etc).
@return {String} A normalized text with type and blueprint prefix.
*/
_friendlyText: function(text, testType, blueprintType) {
var ret = testType + SEPARATOR;
if (blueprintType) {
ret += blueprintType + SEPARATOR;
}
ret += this.humanize(text)
return ret;
},

/**
Return a friendly test name with type prefix
Unit | Components | x-foo
```javascript
name("x-foo", "Unit", "Component") // Unit | Component | x foo
name("x-foo", "Unit", "Component") // Unit | Component | x foo
```
@method name
Expand All @@ -47,20 +63,14 @@ module.exports = {
*/

name: function(name, testType, blueprintType) {
var ret;
if (blueprintType){
ret = testType + SEPARATOR + blueprintType + SEPARATOR + this.humanize(name);
} else {
ret = testType + SEPARATOR + this.humanize(name);
}
return ret;
return this._friendlyText(name, testType, blueprintType);
},

/**
Return a friendly test description
```javascript
description("x-foo", "Unit", "Component") // Unit | Component | x foo
description("x-foo", "Unit", "Component") // Unit | Component | x foo
```
@method description
Expand All @@ -71,13 +81,7 @@ module.exports = {
*/

description: function(description, testType, blueprintType) {
var ret;
if (blueprintType){
ret = testType + SEPARATOR + blueprintType + SEPARATOR + this.humanize(description);
} else {
ret = testType + SEPARATOR + this.humanize(description);
}
return ret;
return this._friendlyText(description, testType, blueprintType);
}

};

0 comments on commit 69087f8

Please sign in to comment.