Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplication in lib/utilities/test-info #4123

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}

};