UNPKG

1.13 kBJavaScriptView Raw
1const print = require("../src/messenger");
2let { commandLabel, classLabel, raw } = require("./testUtils");
3
4const icons = print.icons;
5const messageColor = print.messageColors;
6
7const commandTest = command => {
8 let message = `${command} message`;
9 let tests = [
10 [message, "", false, message],
11 [message, command, false, command],
12 [message, command.toUpperCase(), false, command.toUpperCase()],
13 [message, "TEST_LABEL", false, messageColor[command].fg],
14 [message, "TEST_LABEL", false, messageColor[command].bg],
15 [message, "", true, icons[command]]
16 ];
17 test.each(tests)(`.${command}(%p, %p, %s)`, (msg, label, icon, expected) => {
18 let result = print[command](msg, label, icon);
19 expect(raw(result)).toContain(expected);
20 });
21};
22
23describe(classLabel("Messenger Class"), () => {
24 let commands = [
25 "critical",
26 "error",
27 "success",
28 "warning",
29 "warn",
30 "important",
31 "info",
32 "note",
33 "notice",
34 "log",
35 "debug",
36 "status"
37 ];
38 commands.forEach(command => {
39 describe(commandLabel(`.${command}`), () => {
40 commandTest(command);
41 });
42 });
43});