Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test all text functions in colors module #553

Merged
merged 4 commits into from
Aug 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 105 additions & 9 deletions colors/test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,121 @@
// 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 * as c from "./mod.ts";
import "../examples/colors.ts";

test(function singleColor(): void {
assertEquals(red("Hello world"), "[31mHello world[39m");
assertEquals(c.red("foo bar"), "[31mfoo bar[39m");
});

test(function doubleColor(): void {
assertEquals(bgBlue(red("Hello world")), "[44m[31mHello world[39m[49m");
assertEquals(c.bgBlue(c.red("foo bar")), "[44m[31mfoo bar[39m[49m");
});

test(function replacesCloseCharacters(): void {
assertEquals(red("Hel[39mlo"), "[31mHel[31mlo[39m");
assertEquals(c.red("Hel[39mlo"), "[31mHel[31mlo[39m");
});

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

test(function testBold(): void {
assertEquals(c.bold("foo bar"), "foo bar");
});

test(function testDim(): void {
assertEquals(c.dim("foo bar"), "foo bar");
});

test(function testItalic(): void {
assertEquals(c.italic("foo bar"), "foo bar");
});

test(function testUnderline(): void {
assertEquals(c.underline("foo bar"), "foo bar");
});

test(function testInverse(): void {
assertEquals(c.inverse("foo bar"), "foo bar");
});

test(function testHidden(): void {
assertEquals(c.hidden("foo bar"), "foo bar");
});

test(function testStrikethrough(): void {
assertEquals(c.strikethrough("foo bar"), "foo bar");
});

test(function testBlack(): void {
assertEquals(c.black("foo bar"), "foo bar");
});

test(function testRed(): void {
assertEquals(c.red("foo bar"), "foo bar");
});

test(function testGreen(): void {
assertEquals(c.green("foo bar"), "foo bar");
});

test(function testYellow(): void {
assertEquals(c.yellow("foo bar"), "foo bar");
});

test(function testBlue(): void {
assertEquals(c.blue("foo bar"), "foo bar");
});

test(function testMagenta(): void {
assertEquals(c.magenta("foo bar"), "foo bar");
});

test(function testCyan(): void {
assertEquals(c.cyan("foo bar"), "foo bar");
});

test(function testWhite(): void {
assertEquals(c.white("foo bar"), "foo bar");
});

test(function testGray(): void {
assertEquals(c.gray("foo bar"), "foo bar");
});

test(function testBgBlack(): void {
assertEquals(c.bgBlack("foo bar"), "foo bar");
});

test(function testBgRed(): void {
assertEquals(c.bgRed("foo bar"), "foo bar");
});

test(function testBgGreen(): void {
assertEquals(c.bgGreen("foo bar"), "foo bar");
});

test(function testBgYellow(): void {
assertEquals(c.bgYellow("foo bar"), "foo bar");
});

test(function testBgBlue(): void {
assertEquals(c.bgBlue("foo bar"), "foo bar");
});

test(function testBgMagenta(): void {
assertEquals(c.bgMagenta("foo bar"), "foo bar");
});

test(function testBgCyan(): void {
assertEquals(c.bgCyan("foo bar"), "foo bar");
});

test(function testBgWhite(): void {
assertEquals(c.bgWhite("foo bar"), "foo bar");
});