|
1 |
| -import { green, red, gray } from "colorette" |
| 1 | +import { gray, green, red } from "colorette" |
2 | 2 | import assert from "node:assert/strict"
|
3 | 3 | import { suite, test } from "node:test"
|
4 | 4 | import stripAnsi from "strip-ansi"
|
5 | 5 | import * as assertNoDiff from "../src/index"
|
6 | 6 |
|
7 |
| -suite("assertNoDiff.chars()", function () { |
8 |
| - test("matching data", function () { |
| 7 | +suite("assertNoDiff.chars()", function() { |
| 8 | + test("matching data", function() { |
9 | 9 | const data = "Jean-Luc Picard"
|
10 | 10 | assertNoDiff.chars(data, data)
|
11 | 11 | })
|
12 | 12 |
|
13 |
| - test("mismatching data", function () { |
| 13 | + test("mismatching data", function() { |
14 | 14 | const obj1 = "Jean-Luc Picard"
|
15 | 15 | const obj2 = "Captain Picard"
|
16 | 16 | const expected = `mismatching strings:
|
17 | 17 |
|
18 | 18 | ${red("Je")}${green("C")}${gray("a")}${green("ptai")}${gray("n")}${red("-Luc")}${gray(" Picard")}`
|
19 | 19 | assert.throws(
|
20 |
| - function () { |
| 20 | + function() { |
21 | 21 | assertNoDiff.chars(obj2, obj1)
|
22 | 22 | },
|
23 | 23 | new Error(expected),
|
24 | 24 | "should throw color-coded diff"
|
25 | 25 | )
|
26 | 26 | })
|
27 | 27 |
|
28 |
| - // test("no expected value", function () { |
29 |
| - // assert.throws(function () { |
30 |
| - // // @ts-ignore: intentional call without second argument |
31 |
| - // assertNoDiff.chars("foo") |
32 |
| - // }, new Error("AssertNoDiff: expected value not provided")) |
33 |
| - // }) |
| 28 | + test("no expected value", function() { |
| 29 | + assert.throws(function() { |
| 30 | + // @ts-ignore: intentional call without second argument |
| 31 | + assertNoDiff.chars("foo") |
| 32 | + }, new Error("AssertNoDiff: expected value not provided")) |
| 33 | + }) |
34 | 34 |
|
35 |
| - // test("no actual value", function () { |
36 |
| - // assert.throws(function () { |
37 |
| - // // @ts-ignore: intentional call without arguments |
38 |
| - // assertNoDiff.chars() |
39 |
| - // }, new Error("AssertNoDiff: actual value not provided")) |
40 |
| - // }) |
| 35 | + test("no actual value", function() { |
| 36 | + assert.throws(function() { |
| 37 | + // @ts-ignore: intentional call without arguments |
| 38 | + assertNoDiff.chars() |
| 39 | + }, new Error("AssertNoDiff: actual value not provided")) |
| 40 | + }) |
41 | 41 |
|
42 |
| - // test("providing a custom message", function () { |
43 |
| - // try { |
44 |
| - // assertNoDiff.chars("one", "two", "custom message") |
45 |
| - // } catch (e) { |
46 |
| - // const stripped = stripAnsi(e.message) |
47 |
| - // assert.equal(stripped, "custom message:\n\ntwone") |
48 |
| - // return |
49 |
| - // } |
50 |
| - // throw new Error("assertNoDiff.chars didn't throw") |
51 |
| - // }) |
| 42 | + test("providing a custom message", function() { |
| 43 | + try { |
| 44 | + assertNoDiff.chars("one", "two", "custom message") |
| 45 | + } catch (e) { |
| 46 | + const stripped = stripAnsi(e.message) |
| 47 | + assert.equal(stripped, "custom message:\n\ntwone") |
| 48 | + return |
| 49 | + } |
| 50 | + throw new Error("assertNoDiff.chars didn't throw") |
| 51 | + }) |
52 | 52 |
|
53 |
| - // test("diffing against empty strings", function () { |
54 |
| - // assertNoDiff.chars("", "") |
55 |
| - // }) |
| 53 | + test("diffing against empty strings", function() { |
| 54 | + assertNoDiff.chars("", "") |
| 55 | + }) |
56 | 56 | })
|
0 commit comments