From e15d65fda97db1d6671115e177ac09a38dd47efa Mon Sep 17 00:00:00 2001 From: Eugen Cazacu Date: Thu, 8 Aug 2019 22:56:05 +0200 Subject: [PATCH 1/4] test all text function in colors module --- colors/test.ts | 125 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/colors/test.ts b/colors/test.ts index 26e34c742cb6..45cdce2ef707 100644 --- a/colors/test.ts +++ b/colors/test.ts @@ -1,7 +1,34 @@ // 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 { + red, + bgBlue, + setEnabled, + getEnabled, + bold, + dim, + italic, + underline, + inverse, + hidden, + strikethrough, + black, + green, + yellow, + blue, + magenta, + cyan, + white, + gray, + bgBlack, + bgRed, + bgGreen, + bgYellow, + bgMagenta, + bgCyan, + bgWhite +} from "./mod.ts"; import "../examples/colors.ts"; test(function singleColor(): void { @@ -23,3 +50,99 @@ test(function enablingColors(): void { setEnabled(true); assertEquals(red("Hello world"), "Hello world"); }); + +test(function testBold(): void { + assertEquals(bold("Hello world"), "Hello world"); +}); + +test(function testDim(): void { + assertEquals(dim("Hello world"), "Hello world"); +}); + +test(function testItalic(): void { + assertEquals(italic("Hello world"), "Hello world"); +}); + +test(function testUnderline(): void { + assertEquals(underline("Hello world"), "Hello world"); +}); + +test(function testInverse(): void { + assertEquals(inverse("Hello world"), "Hello world"); +}); + +test(function testHidden(): void { + assertEquals(hidden("Hello world"), "Hello world"); +}); + +test(function testStrikethrough(): void { + assertEquals(strikethrough("Hello world"), "Hello world"); +}); + +test(function testBlack(): void { + assertEquals(black("Hello world"), "Hello world"); +}); + +test(function testRed(): void { + assertEquals(red("Hello world"), "Hello world"); +}); + +test(function testGreen(): void { + assertEquals(green("Hello world"), "Hello world"); +}); + +test(function testYellow(): void { + assertEquals(yellow("Hello world"), "Hello world"); +}); + +test(function testBlue(): void { + assertEquals(blue("Hello world"), "Hello world"); +}); + +test(function testMagenta(): void { + assertEquals(magenta("Hello world"), "Hello world"); +}); + +test(function testCyan(): void { + assertEquals(cyan("Hello world"), "Hello world"); +}); + +test(function testWhite(): void { + assertEquals(white("Hello world"), "Hello world"); +}); + +test(function testGray(): void { + assertEquals(gray("Hello world"), "Hello world"); +}); + +test(function testBgBlack(): void { + assertEquals(bgBlack("Hello world"), "Hello world"); +}); + +test(function testBgRed(): void { + assertEquals(bgRed("Hello world"), "Hello world"); +}); + +test(function testBgGreen(): void { + assertEquals(bgGreen("Hello world"), "Hello world"); +}); + +test(function testBgYellow(): void { + assertEquals(bgYellow("Hello world"), "Hello world"); +}); + +test(function testBgBlue(): void { + assertEquals(bgBlue("Hello world"), "Hello world"); +}); + +test(function testBgMagenta(): void { + assertEquals(bgMagenta("Hello world"), "Hello world"); +}); + +test(function testBgCyan(): void { + assertEquals(bgCyan("Hello world"), "Hello world"); +}); + +test(function testBgWhite(): void { + assertEquals(bgWhite("Hello world"), "Hello world"); +}); From f4333bd4c250cb476c4472dc9cb4d9c26b4e1ad3 Mon Sep 17 00:00:00 2001 From: Eugen Cazacu <32613393+oygen87@users.noreply.github.com> Date: Fri, 9 Aug 2019 20:21:33 +0200 Subject: [PATCH 2/4] refactor, wildcard import --- colors/test.ts | 93 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/colors/test.ts b/colors/test.ts index 45cdce2ef707..8f42e6c5e997 100644 --- a/colors/test.ts +++ b/colors/test.ts @@ -1,148 +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, - bold, - dim, - italic, - underline, - inverse, - hidden, - strikethrough, - black, - green, - yellow, - blue, - magenta, - cyan, - white, - gray, - bgBlack, - bgRed, - bgGreen, - bgYellow, - bgMagenta, - bgCyan, - bgWhite -} from "./mod.ts"; +import * as _ from "./mod.ts"; import "../examples/colors.ts"; test(function singleColor(): void { - assertEquals(red("Hello world"), "Hello world"); + assertEquals(_.red("foo bar"), "foo bar"); }); test(function doubleColor(): void { - assertEquals(bgBlue(red("Hello world")), "Hello world"); + assertEquals(_.bgBlue(_.red("foo bar")), "foo bar"); }); test(function replacesCloseCharacters(): void { - assertEquals(red("Hello"), "Hello"); + 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"); + assertEquals(_.getEnabled(), true); + _.setEnabled(false); + assertEquals(_.bgBlue(_.red("foo bar")), "foo bar"); + _.setEnabled(true); + assertEquals(_.red("foo bar"), "foo bar"); }); test(function testBold(): void { - assertEquals(bold("Hello world"), "Hello world"); + assertEquals(_.bold("foo bar"), "foo bar"); }); test(function testDim(): void { - assertEquals(dim("Hello world"), "Hello world"); + assertEquals(_.dim("foo bar"), "foo bar"); }); test(function testItalic(): void { - assertEquals(italic("Hello world"), "Hello world"); + assertEquals(_.italic("foo bar"), "foo bar"); }); test(function testUnderline(): void { - assertEquals(underline("Hello world"), "Hello world"); + assertEquals(_.underline("foo bar"), "foo bar"); }); test(function testInverse(): void { - assertEquals(inverse("Hello world"), "Hello world"); + assertEquals(_.inverse("foo bar"), "foo bar"); }); test(function testHidden(): void { - assertEquals(hidden("Hello world"), "Hello world"); + assertEquals(_.hidden("foo bar"), "foo bar"); }); test(function testStrikethrough(): void { - assertEquals(strikethrough("Hello world"), "Hello world"); + assertEquals(_.strikethrough("foo bar"), "foo bar"); }); test(function testBlack(): void { - assertEquals(black("Hello world"), "Hello world"); + assertEquals(_.black("foo bar"), "foo bar"); }); test(function testRed(): void { - assertEquals(red("Hello world"), "Hello world"); + assertEquals(_.red("foo bar"), "foo bar"); }); test(function testGreen(): void { - assertEquals(green("Hello world"), "Hello world"); + assertEquals(_.green("foo bar"), "foo bar"); }); test(function testYellow(): void { - assertEquals(yellow("Hello world"), "Hello world"); + assertEquals(_.yellow("foo bar"), "foo bar"); }); test(function testBlue(): void { - assertEquals(blue("Hello world"), "Hello world"); + assertEquals(_.blue("foo bar"), "foo bar"); }); test(function testMagenta(): void { - assertEquals(magenta("Hello world"), "Hello world"); + assertEquals(_.magenta("foo bar"), "foo bar"); }); test(function testCyan(): void { - assertEquals(cyan("Hello world"), "Hello world"); + assertEquals(_.cyan("foo bar"), "foo bar"); }); test(function testWhite(): void { - assertEquals(white("Hello world"), "Hello world"); + assertEquals(_.white("foo bar"), "foo bar"); }); test(function testGray(): void { - assertEquals(gray("Hello world"), "Hello world"); + assertEquals(_.gray("foo bar"), "foo bar"); }); test(function testBgBlack(): void { - assertEquals(bgBlack("Hello world"), "Hello world"); + assertEquals(_.bgBlack("foo bar"), "foo bar"); }); test(function testBgRed(): void { - assertEquals(bgRed("Hello world"), "Hello world"); + assertEquals(_.bgRed("foo bar"), "foo bar"); }); test(function testBgGreen(): void { - assertEquals(bgGreen("Hello world"), "Hello world"); + assertEquals(_.bgGreen("foo bar"), "foo bar"); }); test(function testBgYellow(): void { - assertEquals(bgYellow("Hello world"), "Hello world"); + assertEquals(_.bgYellow("foo bar"), "foo bar"); }); test(function testBgBlue(): void { - assertEquals(bgBlue("Hello world"), "Hello world"); + assertEquals(_.bgBlue("foo bar"), "foo bar"); }); test(function testBgMagenta(): void { - assertEquals(bgMagenta("Hello world"), "Hello world"); + assertEquals(_.bgMagenta("foo bar"), "foo bar"); }); test(function testBgCyan(): void { - assertEquals(bgCyan("Hello world"), "Hello world"); + assertEquals(_.bgCyan("foo bar"), "foo bar"); }); test(function testBgWhite(): void { - assertEquals(bgWhite("Hello world"), "Hello world"); + assertEquals(_.bgWhite("foo bar"), "foo bar"); }); From bf9be49cf06df7e7c0c640b6cba5cd6cbaca8e70 Mon Sep 17 00:00:00 2001 From: Eugen Cazacu <32613393+oygen87@users.noreply.github.com> Date: Mon, 12 Aug 2019 17:12:12 +0200 Subject: [PATCH 3/4] change variable name in colors wildcard import --- colors/test.ts | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/colors/test.ts b/colors/test.ts index 8f42e6c5e997..3456e9f055c5 100644 --- a/colors/test.ts +++ b/colors/test.ts @@ -1,121 +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 * as _ from "./mod.ts"; +import * as c from "./mod.ts"; import "../examples/colors.ts"; test(function singleColor(): void { - assertEquals(_.red("foo bar"), "foo bar"); + assertEquals(c.red("foo bar"), "foo bar"); }); test(function doubleColor(): void { - assertEquals(_.bgBlue(_.red("foo bar")), "foo bar"); + assertEquals(c.bgBlue(c.red("foo bar")), "foo bar"); }); test(function replacesCloseCharacters(): void { - assertEquals(_.red("Hello"), "Hello"); + assertEquals(c.red("Hello"), "Hello"); }); test(function enablingColors(): void { - assertEquals(_.getEnabled(), true); - _.setEnabled(false); - assertEquals(_.bgBlue(_.red("foo bar")), "foo bar"); - _.setEnabled(true); - assertEquals(_.red("foo bar"), "foo bar"); + 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(_.bold("foo bar"), "foo bar"); + assertEquals(c.bold("foo bar"), "foo bar"); }); test(function testDim(): void { - assertEquals(_.dim("foo bar"), "foo bar"); + assertEquals(c.dim("foo bar"), "foo bar"); }); test(function testItalic(): void { - assertEquals(_.italic("foo bar"), "foo bar"); + assertEquals(c.italic("foo bar"), "foo bar"); }); test(function testUnderline(): void { - assertEquals(_.underline("foo bar"), "foo bar"); + assertEquals(c.underline("foo bar"), "foo bar"); }); test(function testInverse(): void { - assertEquals(_.inverse("foo bar"), "foo bar"); + assertEquals(c.inverse("foo bar"), "foo bar"); }); test(function testHidden(): void { - assertEquals(_.hidden("foo bar"), "foo bar"); + assertEquals(c.hidden("foo bar"), "foo bar"); }); test(function testStrikethrough(): void { - assertEquals(_.strikethrough("foo bar"), "foo bar"); + assertEquals(c.strikethrough("foo bar"), "foo bar"); }); test(function testBlack(): void { - assertEquals(_.black("foo bar"), "foo bar"); + assertEquals(c.black("foo bar"), "foo bar"); }); test(function testRed(): void { - assertEquals(_.red("foo bar"), "foo bar"); + assertEquals(c.red("foo bar"), "foo bar"); }); test(function testGreen(): void { - assertEquals(_.green("foo bar"), "foo bar"); + assertEquals(c.green("foo bar"), "foo bar"); }); test(function testYellow(): void { - assertEquals(_.yellow("foo bar"), "foo bar"); + assertEquals(c.yellow("foo bar"), "foo bar"); }); test(function testBlue(): void { - assertEquals(_.blue("foo bar"), "foo bar"); + assertEquals(c.blue("foo bar"), "foo bar"); }); test(function testMagenta(): void { - assertEquals(_.magenta("foo bar"), "foo bar"); + assertEquals(c.magenta("foo bar"), "foo bar"); }); test(function testCyan(): void { - assertEquals(_.cyan("foo bar"), "foo bar"); + assertEquals(c.cyan("foo bar"), "foo bar"); }); test(function testWhite(): void { - assertEquals(_.white("foo bar"), "foo bar"); + assertEquals(c.white("foo bar"), "foo bar"); }); test(function testGray(): void { - assertEquals(_.gray("foo bar"), "foo bar"); + assertEquals(c.gray("foo bar"), "foo bar"); }); test(function testBgBlack(): void { - assertEquals(_.bgBlack("foo bar"), "foo bar"); + assertEquals(c.bgBlack("foo bar"), "foo bar"); }); test(function testBgRed(): void { - assertEquals(_.bgRed("foo bar"), "foo bar"); + assertEquals(c.bgRed("foo bar"), "foo bar"); }); test(function testBgGreen(): void { - assertEquals(_.bgGreen("foo bar"), "foo bar"); + assertEquals(c.bgGreen("foo bar"), "foo bar"); }); test(function testBgYellow(): void { - assertEquals(_.bgYellow("foo bar"), "foo bar"); + assertEquals(c.bgYellow("foo bar"), "foo bar"); }); test(function testBgBlue(): void { - assertEquals(_.bgBlue("foo bar"), "foo bar"); + assertEquals(c.bgBlue("foo bar"), "foo bar"); }); test(function testBgMagenta(): void { - assertEquals(_.bgMagenta("foo bar"), "foo bar"); + assertEquals(c.bgMagenta("foo bar"), "foo bar"); }); test(function testBgCyan(): void { - assertEquals(_.bgCyan("foo bar"), "foo bar"); + assertEquals(c.bgCyan("foo bar"), "foo bar"); }); test(function testBgWhite(): void { - assertEquals(_.bgWhite("foo bar"), "foo bar"); + assertEquals(c.bgWhite("foo bar"), "foo bar"); }); From 88c59b19841ada316fd9a945bfd54a7c95cd273a Mon Sep 17 00:00:00 2001 From: Eugen Cazacu <32613393+oygen87@users.noreply.github.com> Date: Mon, 12 Aug 2019 17:50:43 +0200 Subject: [PATCH 4/4] Update test.ts --- colors/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colors/test.ts b/colors/test.ts index 3456e9f055c5..dec246fb0c73 100644 --- a/colors/test.ts +++ b/colors/test.ts @@ -29,7 +29,7 @@ test(function testBold(): void { }); test(function testDim(): void { - assertEquals(c.dim("foo bar"), "foo bar"); + assertEquals(c.dim("foo bar"), "foo bar"); }); test(function testItalic(): void {