|
3 | 3 | const { test } = require('tap')
|
4 | 4 | const utils = require('../lib/utils')
|
5 | 5 |
|
| 6 | +// We aren't testing the chalk library, so strip off the colors/styles it adds |
| 7 | +const stripAnsiRegex = |
| 8 | +/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g |
| 9 | + |
6 | 10 | test('test utility functions', (t) => {
|
7 | 11 | t.test('test rightPad function - with padding', (tt) => {
|
8 | 12 | const padded = utils.rightPad('string', 10)
|
@@ -36,5 +40,37 @@ test('test utility functions', (t) => {
|
36 | 40 | tt.end()
|
37 | 41 | })
|
38 | 42 |
|
| 43 | + t.test('test headers function - skip', (tt) => { |
| 44 | + const header = utils.header('abc123', 'skip') |
| 45 | + tt.equal(header.replace(stripAnsiRegex, ''), |
| 46 | + '✔ abc123 # SKIPPED', |
| 47 | + 'should be equal') |
| 48 | + tt.end() |
| 49 | + }) |
| 50 | + |
| 51 | + t.test('test headers function - pass', (tt) => { |
| 52 | + const header = utils.header('abc123', 'pass') |
| 53 | + tt.equal(header.replace(stripAnsiRegex, ''), |
| 54 | + '✔ abc123', |
| 55 | + 'should be equal') |
| 56 | + tt.end() |
| 57 | + }) |
| 58 | + |
| 59 | + t.test('test headers function - pass', (tt) => { |
| 60 | + const header = utils.header('abc123', 'pass') |
| 61 | + tt.equal(header.replace(stripAnsiRegex, ''), |
| 62 | + '✔ abc123', |
| 63 | + 'should be equal') |
| 64 | + tt.end() |
| 65 | + }) |
| 66 | + |
| 67 | + t.test('test headers function - fail', (tt) => { |
| 68 | + const header = utils.header('abc123', 'fail') |
| 69 | + tt.equal(header.replace(stripAnsiRegex, ''), |
| 70 | + '✖ abc123', |
| 71 | + 'should be equal') |
| 72 | + tt.end() |
| 73 | + }) |
| 74 | + |
39 | 75 | t.end()
|
40 | 76 | })
|
0 commit comments