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
|
Description: switch test from ava to tape
Author: Xavier Guimard <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2019-12-21
--- a/test/test.js
+++ b/test/test.js
@@ -1,22 +1,25 @@
-import test from 'ava';
-import style from '..';
+const test = require('tape');
+const style = require('..');
test('return ANSI escape codes', t => {
t.is(style.green.open, '\u001B[32m');
t.is(style.bgGreen.open, '\u001B[42m');
t.is(style.green.close, '\u001B[39m');
t.is(style.gray.open, style.grey.open);
+ t.end();
});
test('group related codes into categories', t => {
t.is(style.color.magenta, style.magenta);
t.is(style.bgColor.bgYellow, style.bgYellow);
t.is(style.modifier.bold, style.bold);
+ t.end();
});
test('groups should not be enumerable', t => {
t.not(Object.getOwnPropertyDescriptor(style, 'modifier'), undefined);
t.false(Object.keys(style).includes('modifier'));
+ t.end();
});
test('don\'t pollute other objects', t => {
@@ -25,27 +28,29 @@
obj1.foo = true;
t.not(obj1.foo, obj2.foo);
+ t.end();
});
test('all color types are always available', t => {
const {ansi, ansi256, ansi16m} = style.color;
- t.truthy(ansi);
- t.truthy(ansi.ansi);
- t.truthy(ansi.ansi256);
-
- t.truthy(ansi256);
- t.truthy(ansi256.ansi);
- t.truthy(ansi256.ansi256);
-
- t.truthy(ansi16m);
- t.truthy(ansi16m.ansi);
- t.truthy(ansi16m.ansi256);
+ t.true(ansi);
+ t.true(ansi.ansi);
+ t.true(ansi.ansi256);
+
+ t.true(ansi256);
+ t.true(ansi256.ansi);
+ t.true(ansi256.ansi256);
+
+ t.true(ansi16m);
+ t.true(ansi16m.ansi);
+ t.true(ansi16m.ansi256);
// There are no such things as ansi16m source colors
- t.falsy(ansi.ansi16m);
- t.falsy(ansi256.ansi16m);
- t.falsy(ansi16m.ansi16m);
+ t.false(ansi.ansi16m);
+ t.false(ansi256.ansi16m);
+ t.false(ansi16m.ansi16m);
+ t.end();
});
test('support conversion to ansi (16 colors)', t => {
@@ -58,6 +63,7 @@
t.is(style.bgColor.ansi.hsl(140, 100, 50), '\u001B[102m');
t.is(style.bgColor.ansi.hex('#990099'), '\u001B[45m');
t.is(style.bgColor.ansi.hex('#FF00FF'), '\u001B[105m');
+ t.end();
});
test('support conversion to ansi (256 colors)', t => {
@@ -70,6 +76,7 @@
t.is(style.bgColor.ansi256.hsl(140, 100, 50), '\u001B[48;5;48m');
t.is(style.bgColor.ansi256.hex('#990099'), '\u001B[48;5;127m');
t.is(style.bgColor.ansi256.hex('#FF00FF'), '\u001B[48;5;201m');
+ t.end();
});
test('support conversion to ansi (16 million colors)', t => {
@@ -82,11 +89,13 @@
t.is(style.bgColor.ansi16m.hsl(140, 100, 50), '\u001B[48;2;0;255;85m');
t.is(style.bgColor.ansi16m.hex('#990099'), '\u001B[48;2;153;0;153m');
t.is(style.bgColor.ansi16m.hex('#FF00FF'), '\u001B[48;2;255;0;255m');
+ t.end();
});
test('16/256/16m color close escapes', t => {
t.is(style.color.close, '\u001B[39m');
t.is(style.bgColor.close, '\u001B[49m');
+ t.end();
});
test('export raw ANSI escape codes', t => {
@@ -95,8 +104,10 @@
t.is(style.codes.get(91), 39);
t.is(style.codes.get(40), 49);
t.is(style.codes.get(100), 49);
+ t.end();
});
test('rgb -> truecolor is stubbed', t => {
t.is(style.color.ansi16m.rgb(123, 45, 67), '\u001B[38;2;123;45;67m');
+ t.end();
});
|