2019-02-07 11:45:47 -05:00
|
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-06 16:39:50 -05:00
|
|
|
|
import { test } from "../testing/mod.ts";
|
2019-03-06 19:42:24 -05:00
|
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2019-01-19 05:09:35 -05:00
|
|
|
|
import { red, bgBlue, setEnabled, getEnabled } from "./mod.ts";
|
2019-03-18 11:08:01 -04:00
|
|
|
|
import "../examples/colors.ts";
|
2018-12-18 23:30:44 -05:00
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
|
test(function singleColor(): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(red("Hello world"), "[31mHello world[39m");
|
2018-12-18 23:30:44 -05:00
|
|
|
|
});
|
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
|
test(function doubleColor(): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
|
2019-01-15 16:16:52 -05:00
|
|
|
|
});
|
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
|
test(function replacesCloseCharacters(): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(red("Hel[39mlo"), "[31mHel[31mlo[39m");
|
2019-01-15 16:16:52 -05:00
|
|
|
|
});
|
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
|
test(function enablingColors(): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(getEnabled(), true);
|
2019-01-19 05:09:35 -05:00
|
|
|
|
setEnabled(false);
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(bgBlue(red("Hello world")), "Hello world");
|
2019-03-03 17:21:24 -05:00
|
|
|
|
setEnabled(true);
|
2019-03-06 19:42:24 -05:00
|
|
|
|
assertEquals(red("Hello world"), "[31mHello world[39m");
|
2018-12-18 23:30:44 -05:00
|
|
|
|
});
|