var assert = require('assert');
var P = require('./privilege.js');
var message = "Authentication is needed to run /usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev && udevadm trigger --subsystem-match=i2c-dev as the super user";
assert.strictEqual(P.commandFromMessage(message), "/usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev && udevadm trigger --subsystem-match=i2c-dev");
assert.strictEqual(P.commandFromMessage("Authentication is needed to run `/usr/bin/sh -c sleep 30' as the super user"), "/usr/bin/sh -c sleep 30");
assert.strictEqual(P.commandFromMessage("Authentication required"), "Authentication required");
assert.deepStrictEqual(P.commandLines("/usr/bin/sh -c pacman -S --needed --noconfirm ddcutil && modprobe i2c-dev"), ["/usr/bin/sh -c", "pacman -S --needed --noconfirm ddcutil", "modprobe i2c-dev"]);
var html = P.commandMarkdown(message);
assert(html.indexOf("font-family:'IBM Plex Mono'") >= 0, "renders a monospace command block");
assert(html.indexOf("/usr/bin/sh -c
") >= 0, "puts shell wrapper on its own line");
assert(html.indexOf("pacman -S --needed --noconfirm ddcutil") >= 0, "splits chained command onto readable line");
assert(html.indexOf("modprobe i2c-dev") >= 0, "shows modprobe line");
assert(html.indexOf("udevadm trigger --subsystem-match=i2c-dev") >= 0, "shows udevadm line");
assert(html.indexOf("&&") < 0, "does not leave && noise in formatted command");
assert.strictEqual(P.escapeHtml("&\""), "<x>&"");
console.log('privilege.test.js: ALL PASS');