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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
Description: replace ava by tape
Author: Yadd <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2022-10-07
--- a/test/chalk.js
+++ b/test/chalk.js
@@ -1,5 +1,5 @@
import process from 'node:process';
-import test from 'ava';
+import test from 'tape';
import chalk, {Chalk, chalkStderr} from '../source/index.js';
chalk.level = 3;
@@ -10,10 +10,12 @@
test('don\'t add any styling when called as the base function', t => {
t.is(chalk('foo'), 'foo');
+ t.end();
});
test('support multiple arguments in base function', t => {
t.is(chalk('hello', 'there'), 'hello there');
+ t.end();
});
test('support automatic casting to string', t => {
@@ -22,17 +24,20 @@
t.is(chalk.bold(['foo', 'bar']), '\u001B[1mfoo,bar\u001B[22m');
t.is(chalk.green(98_765), '\u001B[32m98765\u001B[39m');
+ t.end();
});
test('style string', t => {
t.is(chalk.underline('foo'), '\u001B[4mfoo\u001B[24m');
t.is(chalk.red('foo'), '\u001B[31mfoo\u001B[39m');
t.is(chalk.bgRed('foo'), '\u001B[41mfoo\u001B[49m');
+ t.end();
});
test('support applying multiple styles at once', t => {
t.is(chalk.red.bgGreen.underline('foo'), '\u001B[31m\u001B[42m\u001B[4mfoo\u001B[24m\u001B[49m\u001B[39m');
t.is(chalk.underline.red.bgGreen('foo'), '\u001B[4m\u001B[31m\u001B[42mfoo\u001B[49m\u001B[39m\u001B[24m');
+ t.end();
});
test('support nesting styles', t => {
@@ -40,6 +45,7 @@
chalk.red('foo' + chalk.underline.bgBlue('bar') + '!'),
'\u001B[31mfoo\u001B[4m\u001B[44mbar\u001B[49m\u001B[24m!\u001B[39m',
);
+ t.end();
});
test('support nesting styles of the same type (color, underline, bg)', t => {
@@ -47,10 +53,12 @@
chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m',
);
+ t.end();
});
test('reset all styles with `.reset()`', t => {
t.is(chalk.reset(chalk.red.bgGreen.underline('foo') + 'foo'), '\u001B[0m\u001B[31m\u001B[42m\u001B[4mfoo\u001B[24m\u001B[49m\u001B[39mfoo\u001B[0m');
+ t.end();
});
test('support caching multiple styles', t => {
@@ -61,66 +69,80 @@
t.not(red('foo'), green('foo'));
t.not(redBold('bar'), greenBold('bar'));
t.not(green('baz'), greenBold('baz'));
+ t.end();
});
test('alias gray to grey', t => {
t.is(chalk.grey('foo'), '\u001B[90mfoo\u001B[39m');
+ t.end();
});
test('support variable number of arguments', t => {
t.is(chalk.red('foo', 'bar'), '\u001B[31mfoo bar\u001B[39m');
+ t.end();
});
test('support falsy values', t => {
t.is(chalk.red(0), '\u001B[31m0\u001B[39m');
+ t.end();
});
test('don\'t output escape codes if the input is empty', t => {
t.is(chalk.red(), '');
t.is(chalk.red.blue.black(), '');
+ t.end();
});
test('keep Function.prototype methods', t => {
t.is(Reflect.apply(chalk.grey, null, ['foo']), '\u001B[90mfoo\u001B[39m');
t.is(chalk.reset(chalk.red.bgGreen.underline.bind(null)('foo') + 'foo'), '\u001B[0m\u001B[31m\u001B[42m\u001B[4mfoo\u001B[24m\u001B[49m\u001B[39mfoo\u001B[0m');
t.is(chalk.red.blue.black.call(null), '');
+ t.end();
});
test('line breaks should open and close colors', t => {
t.is(chalk.grey('hello\nworld'), '\u001B[90mhello\u001B[39m\n\u001B[90mworld\u001B[39m');
+ t.end();
});
test('line breaks should open and close colors with CRLF', t => {
t.is(chalk.grey('hello\r\nworld'), '\u001B[90mhello\u001B[39m\r\n\u001B[90mworld\u001B[39m');
+ t.end();
});
test('properly convert RGB to 16 colors on basic color terminals', t => {
t.is(new Chalk({level: 1}).hex('#FF0000')('hello'), '\u001B[91mhello\u001B[39m');
t.is(new Chalk({level: 1}).bgHex('#FF0000')('hello'), '\u001B[101mhello\u001B[49m');
+ t.end();
});
test('properly convert RGB to 256 colors on basic color terminals', t => {
t.is(new Chalk({level: 2}).hex('#FF0000')('hello'), '\u001B[38;5;196mhello\u001B[39m');
t.is(new Chalk({level: 2}).bgHex('#FF0000')('hello'), '\u001B[48;5;196mhello\u001B[49m');
t.is(new Chalk({level: 3}).bgHex('#FF0000')('hello'), '\u001B[48;2;255;0;0mhello\u001B[49m');
+ t.end();
});
test('don\'t emit RGB codes if level is 0', t => {
t.is(new Chalk({level: 0}).hex('#FF0000')('hello'), 'hello');
t.is(new Chalk({level: 0}).bgHex('#FF0000')('hello'), 'hello');
+ t.end();
});
test('supports blackBright color', t => {
t.is(chalk.blackBright('foo'), '\u001B[90mfoo\u001B[39m');
+ t.end();
});
test('sets correct level for chalkStderr and respects it', t => {
t.is(chalkStderr.level, 3);
t.is(chalkStderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
+ t.end();
});
test('keeps function prototype methods', t => {
t.is(chalk.apply(chalk, ['foo']), 'foo');
t.is(chalk.bind(chalk, 'foo')(), 'foo');
t.is(chalk.call(chalk, 'foo'), 'foo');
+ t.end();
});
--- a/test/instance.js
+++ b/test/instance.js
@@ -1,4 +1,4 @@
-import test from 'ava';
+import test from 'tape';
import chalk, {Chalk} from '../source/index.js';
chalk.level = 1;
@@ -9,6 +9,7 @@
t.is(chalk.red('foo'), '\u001B[31mfoo\u001B[39m');
instance.level = 2;
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
+ t.end();
});
test('the `level` option should be a number from 0 to 3', t => {
@@ -21,4 +22,5 @@
new Chalk({level: -1});
}, {message: /should be an integer from 0 to 3/});
/* eslint-enable no-new */
+ t.end();
});
--- a/test/level.js
+++ b/test/level.js
@@ -1,5 +1,5 @@
import {fileURLToPath} from 'node:url';
-import test from 'ava';
+import test from 'tape';
import {execaNode} from 'execa';
import chalk from '../source/index.js';
@@ -10,6 +10,7 @@
chalk.level = 0;
t.is(chalk.red('foo'), 'foo');
chalk.level = oldLevel;
+ t.end();
});
test('enable/disable colors based on overall chalk .level property, not individual instances', t => {
@@ -20,6 +21,7 @@
chalk.level = 0;
t.is(red.level, chalk.level);
chalk.level = oldLevel;
+ t.end();
});
test('propagate enable/disable changes from child colors', t => {
@@ -35,9 +37,11 @@
t.is(red.level, 1);
t.is(chalk.level, 1);
chalk.level = oldLevel;
+ t.end();
});
test('disable colors if they are not supported', async t => {
const {stdout} = await execaNode(fileURLToPath(new URL('_fixture.js', import.meta.url)));
t.is(stdout, 'testout testerr');
+ t.end();
});
--- a/test/no-color-support.js
+++ b/test/no-color-support.js
@@ -1,4 +1,4 @@
-import test from 'ava';
+import test from 'tape';
import chalk from '../source/index.js';
// TODO: Do this when ESM supports loader hooks
@@ -21,4 +21,5 @@
test('colors can be forced by using chalk.level', t => {
chalk.level = 1;
t.is(chalk.green('hello'), '\u001B[32mhello\u001B[39m');
+ t.end();
});
--- a/test/visible.js
+++ b/test/visible.js
@@ -1,4 +1,4 @@
-import test from 'ava';
+import test from 'tape';
import chalk, {Chalk} from '../source/index.js';
chalk.level = 1;
@@ -7,12 +7,14 @@
const instance = new Chalk({level: 3});
t.is(instance.visible.red('foo'), '\u001B[31mfoo\u001B[39m');
t.is(instance.red.visible('foo'), '\u001B[31mfoo\u001B[39m');
+ t.end();
});
test('visible: no output when level is too low', t => {
const instance = new Chalk({level: 0});
t.is(instance.visible.red('foo'), '');
t.is(instance.red.visible('foo'), '');
+ t.end();
});
test('test switching back and forth between level == 0 and level > 0', t => {
@@ -36,4 +38,5 @@
t.is(instance.red.visible('foo'), '\u001B[31mfoo\u001B[39m');
t.is(instance.visible('foo'), 'foo');
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
+ t.end();
});
|