|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const { test } = require('tap') |
| 4 | +const utils = require('../lib/utils') |
| 5 | + |
| 6 | +test('test utility functions', (t) => { |
| 7 | + t.test('test rightPad function - with padding', (tt) => { |
| 8 | + const padded = utils.rightPad('string', 10) |
| 9 | + tt.equal(padded.length, 11, 'should have extra padding') |
| 10 | + tt.equal(padded, 'string ', 'should have padding on the right') |
| 11 | + |
| 12 | + tt.end() |
| 13 | + }) |
| 14 | + |
| 15 | + t.test('test rightPad function - withou padding', (tt) => { |
| 16 | + const padded = utils.rightPad('string', 5) |
| 17 | + tt.equal(padded.length, 6, 'should have the same length') |
| 18 | + tt.equal(padded, 'string', 'should have no padding on the right') |
| 19 | + |
| 20 | + tt.end() |
| 21 | + }) |
| 22 | + |
| 23 | + t.test('test leftPad function - with padding', (tt) => { |
| 24 | + const padded = utils.leftPad('string', 10) |
| 25 | + tt.equal(padded.length, 11, 'should have extra padding') |
| 26 | + tt.equal(padded, ' string', 'should have padding on the left') |
| 27 | + |
| 28 | + tt.end() |
| 29 | + }) |
| 30 | + |
| 31 | + t.test('test leftPad function - withou padding', (tt) => { |
| 32 | + const padded = utils.leftPad('string', 5) |
| 33 | + tt.equal(padded.length, 6, 'should have the same length') |
| 34 | + tt.equal(padded, 'string', 'should have no padding on the left') |
| 35 | + |
| 36 | + tt.end() |
| 37 | + }) |
| 38 | + |
| 39 | + t.end() |
| 40 | +}) |
0 commit comments