diff --git a/tests/chop.js b/tests/chop.js index 8106337c..f087589f 100644 --- a/tests/chop.js +++ b/tests/chop.js @@ -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]'); }); - diff --git a/tests/clean.js b/tests/clean.js index a613cab2..fa952c1a 100644 --- a/tests/clean.js +++ b/tests/clean.js @@ -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'); }); diff --git a/tests/count.js b/tests/count.js index 3e765ed8..08e62e14 100644 --- a/tests/count.js +++ b/tests/count.js @@ -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); @@ -19,4 +20,3 @@ test('#count', function(){ equal(count(null, null), 0); equal(count(undefined, undefined), 0); }); - diff --git a/tests/endsWith.js b/tests/endsWith.js index 5836a534..1f14833c 100644 --- a/tests/endsWith.js +++ b/tests/endsWith.js @@ -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'); @@ -39,4 +40,3 @@ test('#endsWith', function() { strictEqual(endsWith('vader', 'der', 3), false); strictEqual(endsWith('vader', 'der', 4), false); }); - diff --git a/tests/include.js b/tests/include.js index ef2d3a8b..ccf5a751 100644 --- a/tests/include.js +++ b/tests/include.js @@ -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'); }); - diff --git a/tests/insert.js b/tests/insert.js index 612003c0..5af616fb 100644 --- a/tests/insert.js +++ b/tests/insert.js @@ -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'); }); - diff --git a/tests/lpad.js b/tests/lpad.js index d2be7829..898fdeae 100644 --- a/tests/lpad.js +++ b/tests/lpad.js @@ -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'); }); - diff --git a/tests/lrpad.js b/tests/lrpad.js index 0b95088d..948fb4e6 100644 --- a/tests/lrpad.js +++ b/tests/lrpad.js @@ -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'); }); - diff --git a/tests/repeat.js b/tests/repeat.js index 5784d1f7..7102e35a 100644 --- a/tests/repeat.js +++ b/tests/repeat.js @@ -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), ''); }); - diff --git a/tests/rpad.js b/tests/rpad.js index 7cc073ca..be90765b 100644 --- a/tests/rpad.js +++ b/tests/rpad.js @@ -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'); }); -