Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions tests/chop.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
var ok = require('assert').ok;
var deepEqual = require('assert').deepEqual;
var chop = require('../chop');


test('#chop', function(){
ok(chop(null, 2).length === 0, 'output []');
ok(chop('whitespace', 2).length === 5, 'output [wh, it, es, pa, ce]');
ok(chop('whitespace', 3).length === 4, 'output [whi, tes, pac, e]');
ok(chop('whitespace')[0].length === 10, 'output [whitespace]');
ok(chop(12345, 1).length === 5, 'output [1, 2, 3, 4, 5]');
deepEqual(chop(null, 2), [], 'output []');
deepEqual(chop('whitespace', 2), ['wh', 'it', 'es', 'pa', 'ce'], 'output [wh, it, es, pa, ce]');
deepEqual(chop('whitespace', 3), ['whi', 'tes', 'pac', 'e'], 'output [whi, tes, pac, e]');
deepEqual(chop('whitespace'), ['whitespace'], 'output [whitespace]');
deepEqual(chop(12345, 1), ['1', '2', '3', '4', '5'], 'output [1, 2, 3, 4, 5]');
});

9 changes: 5 additions & 4 deletions tests/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var clean = require('../clean');

test('#clean', function() {
equal(clean(' foo bar '), 'foo bar');
equal(clean(123), '123');
equal(clean(''), '', 'claning empty string returns empty string');
equal(clean(null), '', 'claning null returns empty string');
equal(clean(undefined), '', 'claning undefined returns empty string');
equal(clean('foo bar'), 'foo bar', 'cleaning a string not containing multiple spaces returns string itself');
equal(clean(123), '123', 'cleaning number returns it\'s string representation');
equal(clean(''), '', 'cleaning empty string returns empty string');
equal(clean(null), '', 'cleaning null returns empty string');
equal(clean(undefined), '', 'cleaning undefined returns empty string');
});
2 changes: 1 addition & 1 deletion tests/count.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test('#count', function(){
equal(count('Hello world', 'l'), 3);
equal(count('Hello world', 'Hello'), 1);
equal(count('Hello world', 'foo'), 0);
equal(count('Hello world', 'Hello world'), 1);
equal(count('x.xx....x.x', 'x'), 5);
equal(count('', 'x'), 0);
equal(count(null, 'x'), 0);
Expand All @@ -19,4 +20,3 @@ test('#count', function(){
equal(count(null, null), 0);
equal(count(undefined, undefined), 0);
});

2 changes: 1 addition & 1 deletion tests/endsWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var endsWith = require('../endsWith');

test('#endsWith', function() {
ok(endsWith('foobar', 'bar'), 'foobar ends with bar');
ok(endsWith('foobar', ''), 'foobar ends with empty string');
ok(endsWith('foobarfoobar', 'bar'), 'foobar ends with bar');
ok(endsWith('foo', 'o'), 'foobar ends with o');
ok(endsWith('foobar', 'bar'), 'foobar ends with bar');
Expand Down Expand Up @@ -39,4 +40,3 @@ test('#endsWith', function() {
strictEqual(endsWith('vader', 'der', 3), false);
strictEqual(endsWith('vader', 'der', 4), false);
});

2 changes: 1 addition & 1 deletion tests/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ var s = require('../');
test('#include', function() {
ok(include('foobar', 'bar'), 'foobar includes bar');
ok(!include('foobar', 'buzz'), 'foobar does not includes buzz');
ok(include('foobar', ''), 'foobar includes empty string');
ok(include(12345, 34), '12345 includes 34');
ok(!s.contains(12345, 6), '12345 does not include 6');
ok(!include('', 34), 'empty string includes 34');
ok(!include(null, 34), 'null includes 34');
ok(include(null, ''), 'null includes empty string');
});

4 changes: 3 additions & 1 deletion tests/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ test('#insert', function(){
equal(insert('Hello ', 6, 'Jessy'), 'Hello Jessy');
equal(insert('Hello', 0, 'Jessy '), 'Jessy Hello');
equal(insert('Hello ', 100, 'Jessy'), 'Hello Jessy');
equal(insert('Hello', 2, ''), 'Hello');
equal(insert('Hello', 2, null), 'Hello');
equal(insert('Hello', 2, undefined), 'Hello');
equal(insert('', 100, 'Jessy'), 'Jessy');
equal(insert(null, 100, 'Jessy'), 'Jessy');
equal(insert(undefined, 100, 'Jessy'), 'Jessy');
equal(insert(12345, 5, 'Jessy'), '12345Jessy');
equal(insert(12345, 3, 'Jessy'), '123Jessy45');
});

5 changes: 4 additions & 1 deletion tests/lpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ test('#lpad', function() {
equal(lpad('', 2), ' ');
equal(lpad(null, 2), ' ');
equal(lpad(undefined, 2), ' ');
equal(lpad('Hello', 0), 'Hello');
equal(lpad('Hello', -8), 'Hello');
equal(lpad('Hello', undefined), 'Hello');
equal(lpad('Hello', null), 'Hello');
});

5 changes: 4 additions & 1 deletion tests/lrpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ test('#lrpad', function() {
equal(lrpad('', 2), ' ');
equal(lrpad(null, 2), ' ');
equal(lrpad(undefined, 2), ' ');
equal(lrpad('Hello', 0), 'Hello');
equal(lrpad('Hello', -8), 'Hello');
equal(lrpad('Hello', undefined), 'Hello');
equal(lrpad('Hello', null), 'Hello');
});

3 changes: 2 additions & 1 deletion tests/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ test('#repeat', function() {
equal(repeat('', 2), '');
equal(repeat(null, 2), '');
equal(repeat(undefined, 2), '');
equal(repeat('foo', null), '');
equal(repeat('foo', undefined), '');
});

5 changes: 4 additions & 1 deletion tests/rpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ test('#rpad', function() {
equal(rpad('', 2), ' ');
equal(rpad(null, 2), ' ');
equal(rpad(undefined, 2), ' ');
equal(rpad('Hello', 0), 'Hello');
equal(rpad('Hello', -8), 'Hello');
equal(rpad('Hello', undefined), 'Hello');
equal(rpad('Hello', null), 'Hello');
});