Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (43 loc) · 1.27 KB
/
Copy pathindex.js
File metadata and controls
49 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var test = require('../util/test')(__filename);
var capitalize = require('../../packages/string-capitalize');
test('string lowercase', function(t) {
t.plan(2);
t.equal(capitalize('capitals'), 'Capitals');
t.equal(capitalize('some string'), 'Some string');
t.end();
});
test('lowercase remaining string', function(t) {
t.plan(2);
t.equal(capitalize('capiTALS'), 'Capitals');
t.equal(capitalize('some String'), 'Some string');
t.end();
});
test('string already capitalized', function(t) {
t.plan(2);
t.equal(capitalize('Capitals'), 'Capitals');
t.equal(capitalize('ALLCAPS'), 'Allcaps');
t.end();
});
test('non alpha chars', function(t) {
t.plan(3);
t.equal(capitalize('1two'), '1two');
t.equal(capitalize('!important'), '!important');
t.equal(capitalize(' spaces'), ' spaces');
t.end();
});
test('empty string', function(t) {
t.plan(1);
t.equal(capitalize(''), '');
t.end();
});
test('argument not a string', function(t) {
t.plan(7);
t.throws(function() {capitalize();});
t.throws(function() {capitalize(null);});
t.throws(function() {capitalize(95);});
t.throws(function() {capitalize(true);});
t.throws(function() {capitalize({});});
t.throws(function() {capitalize([]);});
t.throws(function() {capitalize(function() {});});
t.end();
});