summaryrefslogtreecommitdiff
path: root/testing/pretty_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-08-14 16:22:31 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-14 10:22:31 -0400
commiteab0647bd1184d0ade9a54b8720eb52300d2ba5d (patch)
treeff6e8da85df5f2c400eb6c02505cdffd380b4e64 /testing/pretty_test.ts
parent63bbe2a2e041388ec167d67c73f497ea7b8590c6 (diff)
refactor 'assertEquals' (denoland/deno_std#560)
* merge 'testing/pretty.ts' into 'testing/asserts.ts' * throw AssertionError in assertEquals * update misc tests use AssertionError Original: https://github.com/denoland/deno_std/commit/ff2d7f24dbc955650a11fc8db2f35c0aa38dcdb1
Diffstat (limited to 'testing/pretty_test.ts')
-rw-r--r--testing/pretty_test.ts93
1 files changed, 0 insertions, 93 deletions
diff --git a/testing/pretty_test.ts b/testing/pretty_test.ts
deleted file mode 100644
index 07ab83d5e..000000000
--- a/testing/pretty_test.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-
-import { test } from "./mod.ts";
-import { red, green, white, gray, bold } from "../colors/mod.ts";
-import { assertEquals } from "./pretty.ts";
-import { assertThrows } from "./asserts.ts";
-
-const createHeader = (): string[] => [
- "",
- "",
- ` ${gray(bold("[Diff]"))} ${red(bold("Left"))} / ${green(bold("Right"))}`,
- "",
- ""
-];
-
-const added: (s: string) => string = (s: string): string => green(bold(s));
-const removed: (s: string) => string = (s: string): string => red(bold(s));
-
-test({
- name: "pass case",
- fn(): void {
- assertEquals({ a: 10 }, { a: 10 });
- assertEquals(true, true);
- assertEquals(10, 10);
- assertEquals("abc", "abc");
- assertEquals({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } });
- }
-});
-
-test({
- name: "failed with number",
- fn(): void {
- assertThrows(
- (): void => assertEquals(1, 2),
- Error,
- [...createHeader(), removed(`- 1`), added(`+ 2`), ""].join("\n")
- );
- }
-});
-
-test({
- name: "failed with number vs string",
- fn(): void {
- assertThrows(
- (): void => assertEquals(1, "1"),
- Error,
- [...createHeader(), removed(`- 1`), added(`+ "1"`)].join("\n")
- );
- }
-});
-
-test({
- name: "failed with array",
- fn(): void {
- assertThrows(
- (): void => assertEquals([1, "2", 3], ["1", "2", 3]),
- Error,
- [
- ...createHeader(),
- white(" Array ["),
- removed(`- 1,`),
- added(`+ "1",`),
- white(' "2",'),
- white(" 3,"),
- white(" ]"),
- ""
- ].join("\n")
- );
- }
-});
-
-test({
- name: "failed with object",
- fn(): void {
- assertThrows(
- (): void => assertEquals({ a: 1, b: "2", c: 3 }, { a: 1, b: 2, c: [3] }),
- Error,
- [
- ...createHeader(),
- white(" Object {"),
- white(` "a": 1,`),
- added(`+ "b": 2,`),
- added(`+ "c": Array [`),
- added(`+ 3,`),
- added(`+ ],`),
- removed(`- "b": "2",`),
- removed(`- "c": 3,`),
- white(" }"),
- ""
- ].join("\n")
- );
- }
-});