cache isArray, test for automatic casting

This commit is contained in:
Toon Baeyens 2020-06-08 15:14:29 +02:00
parent 2451677995
commit 26c73d2b80
3 changed files with 17 additions and 2 deletions

View file

@ -16,6 +16,14 @@ test('support multiple arguments in base function', t => {
t.is(chalk('hello', 'there'), 'hello there');
});
test('support automatic casting to string', t => {
t.is(chalk(['hello', 'there']), 'hello,there');
t.is(chalk(123), '123');
t.is(chalk.bold(['foo', 'bar']), '\u001B[1mfoo,bar\u001B[22m');
t.is(chalk.green(98765), '\u001B[32m98765\u001B[39m');
});
test('style string', t => {
t.is(chalk.underline('foo'), '\u001B[4mfoo\u001B[24m');
t.is(chalk.red('foo'), '\u001B[31mfoo\u001B[39m');