Skip to content

Commit 6834026

Browse files
Create tests for camelCase utility helper
1 parent a66bd43 commit 6834026

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/utilities.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var assert = require('assert');
7+
var utilities = require('../lib/utilities');
8+
9+
/**
10+
* Tests for utilties.
11+
*/
12+
describe('utilties', function() {
13+
14+
describe('`camelCase` helper', function() {
15+
var camelCase = utilities.camelCase;
16+
17+
it('does nothing if the string doesn\'t need to be camel cased', function() {
18+
assert.equal(camelCase(''), '');
19+
assert.equal(camelCase('foo'), 'foo');
20+
assert.equal(camelCase('fooBar'), 'fooBar');
21+
});
22+
23+
it('properly camel cases a string', function() {
24+
assert.equal(camelCase('foo-bar'), 'fooBar');
25+
assert.equal(camelCase('foo-bar-baz'), 'fooBarBaz');
26+
assert.equal(camelCase('CAMEL-CASE'), 'camelCase');
27+
});
28+
29+
it('throws an error if the first argument is invalid', function() {
30+
[undefined, null, 1337, {}, []].forEach(function(parameter) {
31+
assert.throws(function() { camelCase(parameter); });
32+
});
33+
})
34+
});
35+
36+
});

0 commit comments

Comments
 (0)