2019-01-01 22:46:17 -05:00
|
|
|
|
import { assertEqual, test } from "../testing/mod.ts";
|
2019-01-10 20:18:21 -05:00
|
|
|
|
import { color } from "./mod.ts";
|
|
|
|
|
import "./example.ts";
|
2018-12-18 23:30:44 -05:00
|
|
|
|
|
|
|
|
|
test(function singleColor() {
|
|
|
|
|
assertEqual(color.red("Hello world"), "[31mHello world[39m");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test(function doubleColor() {
|
2019-01-15 16:16:52 -05:00
|
|
|
|
assertEqual(color.red.bgBlue("Hello world"),
|
|
|
|
|
"[44m[31mHello world[39m[49m");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test(function newLinesContinueColors() {
|
|
|
|
|
assertEqual(color.red("Hello\nworld"),
|
|
|
|
|
"[31mHello[39m\n[31mworld[39m");
|
|
|
|
|
assertEqual(color.red("Hello\r\nworld"),
|
|
|
|
|
"[31mHello[39m\r\n[31mworld[39m");
|
|
|
|
|
assertEqual(color.red("Hello\n\nworld"),
|
|
|
|
|
"[31mHello[39m\n[31m[39m\n[31mworld[39m");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test(function replacesCloseCharacters() {
|
|
|
|
|
assertEqual(color.red("Hel[39mlo"), "[31mHel[31mlo[39m");
|
2018-12-18 23:30:44 -05:00
|
|
|
|
});
|