This repository has been archived by the owner on Jan 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
36 lines (29 loc) · 1.45 KB
/
test.js
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
const leftPad = require('./');
const test = require('tape');
test('leftPad', assert => {
assert.plan(24);
assert.strictEqual(leftPad('Foo', 5), ' Foo');
assert.strictEqual(leftPad('Foo', 3), 'Foo');
assert.strictEqual(leftPad('Foo', 1), 'Foo');
assert.strictEqual(leftPad('Foo', -1), 'Foo');
assert.strictEqual(leftPad('Foo', 5, 'x'), 'xxFoo');
assert.strictEqual(leftPad('Foo', 3, 'x'), 'Foo');
assert.strictEqual(leftPad('Foo', 1, 'x'), 'Foo');
assert.strictEqual(leftPad('Foo', -1, 'x'), 'Foo');
assert.strictEqual(leftPad(null, 1), 'null');
assert.strictEqual(leftPad(null, 5), ' null');
assert.strictEqual(leftPad(10, 4), ' 10');
assert.strictEqual(leftPad(10, 4, 0), '0010');
assert.strictEqual(leftPad('Foo', 5, ' ', true), 'Foo ');
assert.strictEqual(leftPad('Foo', 3, ' ', true), 'Foo');
assert.strictEqual(leftPad('Foo', 1, ' ', true), 'Foo');
assert.strictEqual(leftPad('Foo', -1, ' ', true), 'Foo');
assert.strictEqual(leftPad('Foo', 5, 'x', true), 'Fooxx');
assert.strictEqual(leftPad('Foo', 3, 'x', true), 'Foo');
assert.strictEqual(leftPad('Foo', 1, 'x', true), 'Foo');
assert.strictEqual(leftPad('Foo', -1, 'x', true), 'Foo');
assert.strictEqual(leftPad(null, 1, ' ', true), 'null');
assert.strictEqual(leftPad(null, 5, ' ', true), 'null ');
assert.strictEqual(leftPad(10, 4, ' ', true), '10 ');
assert.strictEqual(leftPad(10, 4, 0, true), '1000');
});