-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,6 @@ jspm_packages | |
|
||
# Mac OS | ||
.DS_Store | ||
|
||
# Temporary files created by tests | ||
test/temp |
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,21 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Capitalize string. | ||
* | ||
* @param {String} string - The string. | ||
* @return {String} | ||
*/ | ||
function capitalize(string) { | ||
if (typeof string !== 'string') { | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
/** | ||
* Export utilities. | ||
*/ | ||
module.exports = { | ||
capitalize: capitalize | ||
}; |
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
Empty file.
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,32 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
var assert = require('assert'); | ||
var utilities = require('../lib/utilities'); | ||
|
||
/** | ||
* Utilities. | ||
*/ | ||
describe('utilities', function() { | ||
|
||
describe('#capitalize', function() { | ||
var capitalize = utilities.capitalize; | ||
|
||
it('throws an error if first argument is not a string', function() { | ||
[undefined, null, 1, {}, [], Function].forEach(function(argument) { | ||
assert.throws(function() { | ||
capitalize(argument); | ||
}, TypeError); | ||
}); | ||
}); | ||
|
||
it('capitalizes a string', function() { | ||
assert.equal(capitalize(''), ''); | ||
assert.equal(capitalize('foo'), 'Foo'); | ||
assert.equal(capitalize('FOO'), 'FOO'); | ||
}); | ||
}); | ||
|
||
}); |