Debian Codegraph @

cli-color/test/strip.js

raw
1 "use strict";
2
3 var clc = require("../");
4
5 module.exports = function (t, a) {
6 var x = clc.red, y = x.bold;
7
8 a(t("test"), "test", "Plain");
9
10 a(t("\x1bA"), "", "Simple Command Type 1");
11 a(t("\x9bA"), "", "Simple Command Type 2");
12
13 a(t("\x1b[0A"), "", "Single Command");
14 a(t("\x1b[0;A"), "", "Single Separated Command");
15 a(t("\x1b[0;0A"), "", "Two Commands");
16 a(t("\x1b[0;0;A"), "", "Two Separated Commands");
17
18 // Base on index tests.
19 a(t(clc.red("foo")), "foo", "Foreground");
20 a(t(clc.red("foo", "bar", 3)), "foo bar 3", "Foreground: Many args");
21 a(t(clc.red.yellow("foo", "bar", 3)), "foo bar 3", "Foreground: Overriden");
22 a(t(clc.bgRed("foo", "bar")), "foo bar", "Background");
23 a(t(clc.bgRed.bgYellow("foo", "bar", 3)), "foo bar 3", "Background: Overriden");
24
25 a(t(clc.blue.bgYellow("foo", "bar")), "foo bar", "Foreground & Background");
26 a(
27 t(clc.blue.bgYellow.red.bgMagenta("foo", "bar")), "foo bar",
28 "Foreground & Background: Overriden"
29 );
30
31 a(t(clc.bold("foo", "bar")), "foo bar", "Format");
32 a(t(clc.blink("foobar")), "foobar", "Format: blink");
33 a(t(clc.bold.blue("foo", "bar", 3)), "foo bar 3", "Foreground & Format");
34
35 a(t(clc.redBright("foo", "bar")), "foo bar", "Bright");
36 a(t(clc.bgRedBright("foo", 3)), "foo 3", "Bright background");
37
38 a(
39 t(clc.blueBright.bgYellowBright.red.bgMagenta("foo", "bar")), "foo bar",
40 "Foreground & Background: Bright: Overriden"
41 );
42
43 a(t(clc.red.blue("foo")), "foo", "Prioritize the Last Color: Blue");
44 a(t(clc.blue.red("foo")), "foo", "Prioritize the Last Color: Red");
45 a(t(clc.bgRed.bgBlue("foo")), "foo", "Prioritize the Last Background Color: Blue");
46 a(t(clc.bgBlue.bgRed("foo")), "foo", "Prioritize the Last Background Color: Red");
47 a(t(clc.bgRed.red.bgBlue.blue("foo")), "foo", "Prioritize the Last Mixed Style: Blue");
48 a(t(clc.bgBlue.blue.bgRed.red("foo")), "foo", "Prioritize the Last Mixed Style: Red");
49 a(
50 t(clc.bgRed.blue.bgBlue.red("foo")), "foo",
51 "Prioritize the Last Mixed Style: BG Blue and Red"
52 );
53 a(
54 t(clc.bgBlue.red.bgRed.blue("foo")), "foo",
55 "Prioritize the Last Mixed Style: BG Red and Blue"
56 );
57
58 a(t(x("foo", "red") + " " + y("foo", "boldred")), "foo red foo boldred", "Detached extension");
59
60 a(t(clc.erase.screen).replace(/\n/g, ""), "", "Reset");
61
62 a(t(clc.move.up()), "", "Up: No argument");
63 a(t(clc.move.up({})), "", "Up: Not a number");
64 a(t(clc.move.up(-34)), "", "Up: Negative");
65 a(t(clc.move.up(34)), "", "Up: Positive");
66
67 a(t(clc.move.down()), "", "Down: No argument");
68 a(t(clc.move.down({})), "", "Down: Not a number");
69 a(t(clc.move.down(-34)), "", "Down: Negative");
70 a(t(clc.move.down(34)), "", "Down: Positive");
71
72 a(t(clc.move.right()), "", "Right: No argument");
73 a(t(clc.move.right({})), "", "Right: Not a number");
74 a(t(clc.move.right(-34)), "", "Right: Negative");
75 a(t(clc.move.right(34)), "", "Right: Positive");
76
77 a(t(clc.move.left()), "", "Left: No argument");
78 a(t(clc.move.left({})), "", "Left: Not a number");
79 a(t(clc.move.left(-34)), "", "Left: Negative");
80 a(t(clc.move.left(34)), "", "Left: Positive");
81
82 a(t(clc.move()), "", "Move: No arguments");
83 a(t(clc.move({}, {})), "", "Move: Bad arguments");
84 a(t(clc.move({}, 12)), "", "Move: One direction");
85 a(t(clc.move(0, -12)), "", "Move: One negative direction");
86 a(t(clc.move(-42, -2)), "", "Move: two negatives");
87 a(t(clc.move(2, 35)), "", "Move: two positives");
88
89 a(t(clc.move.to()), "", "MoveTo: No arguments");
90 a(t(clc.move.to({}, {})), "", "MoveTo: Bad arguments");
91 a(t(clc.move.to({}, 12)), "", "MoveTo: One direction");
92 a(t(clc.move.to(2, -12)), "", "MoveTo: One negative direction");
93 a(t(clc.move.to(-42, -2)), "", "MoveTo: two negatives");
94 a(t(clc.move.to(2, 35)), "", "MoveTo: two positives");
95
96 a(t(clc.beep), clc.beep, "Beep");
97
98 a(t("test"), "test", "Plain");
99 };