summaryrefslogtreecommitdiff
path: root/colors/test.ts
blob: 26e34c742cb617ba5691fdb08b9f1a3bf373aac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import { red, bgBlue, setEnabled, getEnabled } from "./mod.ts";
import "../examples/colors.ts";

test(function singleColor(): void {
  assertEquals(red("Hello world"), "Hello world");
});

test(function doubleColor(): void {
  assertEquals(bgBlue(red("Hello world")), "Hello world");
});

test(function replacesCloseCharacters(): void {
  assertEquals(red("Hello"), "Hello");
});

test(function enablingColors(): void {
  assertEquals(getEnabled(), true);
  setEnabled(false);
  assertEquals(bgBlue(red("Hello world")), "Hello world");
  setEnabled(true);
  assertEquals(red("Hello world"), "Hello world");
});