diff --git a/test/chars.test.ts b/test/chars.test.ts index f90d676..4964614 100644 --- a/test/chars.test.ts +++ b/test/chars.test.ts @@ -4,41 +4,41 @@ import { suite, test } from "node:test" import stripAnsi from "strip-ansi" import * as assertNoDiff from "../src/index" -suite("assertNoDiff.chars()", function() { - test("matching data", function() { +suite("assertNoDiff.chars()", () => { + test("matching data", () => { const data = "Jean-Luc Picard" assertNoDiff.chars(data, data) }) - test("mismatching data", function() { + test("mismatching data", () => { const obj1 = "Jean-Luc Picard" const obj2 = "Captain Picard" const expected = `mismatching strings: ${red("Je")}${green("C")}${gray("a")}${green("ptai")}${gray("n")}${red("-Luc")}${gray(" Picard")}` assert.throws( - function() { + () => { assertNoDiff.chars(obj2, obj1) }, new Error(expected) ) }) - test("no expected value", function() { - assert.throws(function() { + test("no expected value", () => { + assert.throws(() => { // @ts-ignore: intentional call without second argument assertNoDiff.chars("foo") }, new Error("AssertNoDiff: expected value not provided")) }) - test("no actual value", function() { - assert.throws(function() { + test("no actual value", () => { + assert.throws(() => { // @ts-ignore: intentional call without arguments assertNoDiff.chars() }, new Error("AssertNoDiff: actual value not provided")) }) - test("providing a custom message", function() { + test("providing a custom message", () => { try { assertNoDiff.chars("one", "two", "custom message") } catch (e) { @@ -49,7 +49,7 @@ ${red("Je")}${green("C")}${gray("a")}${green("ptai")}${gray("n")}${red("-Luc")}$ throw new Error("assertNoDiff.chars didn't throw") }) - test("diffing against empty strings", function() { + test("diffing against empty strings", () => { assertNoDiff.chars("", "") }) }) diff --git a/test/json.test.ts b/test/json.test.ts index e0a852d..c4bff78 100644 --- a/test/json.test.ts +++ b/test/json.test.ts @@ -4,13 +4,13 @@ import { suite, test } from "node:test" import stripAnsi from "strip-ansi" import * as assertNoDiff from "../src/index" -suite("assertNoDiff.json", function() { - test("matching data", function() { +suite("assertNoDiff.json", () => { + test("matching data", () => { const data = { firstName: "Jean-Luc", lastName: "Picard" } assertNoDiff.json(data, data) }) - test("mismatching data", function() { + test("mismatching data", () => { const obj1 = { firstName: "Jean-Luc", lastName: "Picard" } const obj2 = { firstName: "Captain", lastName: "Picard" } const expected = `mismatching objects: @@ -19,28 +19,28 @@ ${gray("{\n")}${red(' "firstName": "Jean-Luc",\n')}${green(' "firstName": "Cap gray(' "lastName": "Picard"\n}') }` assert.throws( - function() { + () => { assertNoDiff.json(obj2, obj1) }, new Error(expected) ) }) - test("no expected value", function() { - assert.throws(function() { + test("no expected value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.json("foo") }, new Error("AssertNoDiff: expected value not provided")) }) - test("no actual value", function() { - assert.throws(function() { + test("no actual value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.json() }, new Error("AssertNoDiff: actual value not provided")) }) - test("custom error message", function() { + test("custom error message", () => { try { assertNoDiff.json({ a: 1 }, { a: 2 }, "custom message") } catch (e) { @@ -51,7 +51,7 @@ ${gray("{\n")}${red(' "firstName": "Jean-Luc",\n')}${green(' "firstName": "Cap throw new Error("assertNoDiff.json didn't throw") }) - test("diffing empty objects", function() { + test("diffing empty objects", () => { assertNoDiff.json({}, {}) }) }) diff --git a/test/trimmed-lines.test.ts b/test/trimmed-lines.test.ts index aebf8ee..606a562 100644 --- a/test/trimmed-lines.test.ts +++ b/test/trimmed-lines.test.ts @@ -4,13 +4,13 @@ import { suite, test } from "node:test" import stripAnsi from "strip-ansi" import * as assertNoDiff from "../src/index" -suite("assertNoDiff.trimmedLines", function() { - test("matching data", function() { +suite("assertNoDiff.trimmedLines", () => { + test("matching data", () => { const data = "Jean-Luc Picard" assertNoDiff.trimmedLines(data, data) }) - test("matching data with surrounding whitespace", function() { + test("matching data with surrounding whitespace", () => { const obj1 = "foo" const obj2 = " foo " assertNoDiff.trimmedLines( @@ -20,33 +20,33 @@ suite("assertNoDiff.trimmedLines", function() { ) }) - test("mismatching data", function() { + test("mismatching data", () => { const obj1 = "Jean-Luc\nPicard" const obj2 = "Captain\nPicard" const expected = `mismatching lines: ${red("Jean-Luc\n")}${green("Captain\n")}${gray("Picard")}` - assert.throws(function() { + assert.throws(() => { assertNoDiff.trimmedLines(obj2, obj1) }, new Error(expected)) }) - test("no expected value", function() { - assert.throws(function() { + test("no expected value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.trimmedLines("foo") }, new Error("AssertNoDiff: expected value not provided")) }) - test("no actual value", function() { - assert.throws(function() { + test("no actual value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.trimmedLines() }, new Error("AssertNoDiff: actual value not provided")) }) - test("custom error message", function() { + test("custom error message", () => { try { assertNoDiff.trimmedLines("one", "two", "custom message") } catch (e) { @@ -57,7 +57,7 @@ ${red("Jean-Luc\n")}${green("Captain\n")}${gray("Picard")}` throw new Error("assertNoDiff.trimmedLines didn't throw") }) - test("diffing empty strings", function() { + test("diffing empty strings", () => { assertNoDiff.trimmedLines("", "", "should allow diffing empty strings") }) }) diff --git a/test/words-with-space.test.ts b/test/words-with-space.test.ts index c9d43aa..402fced 100644 --- a/test/words-with-space.test.ts +++ b/test/words-with-space.test.ts @@ -4,31 +4,31 @@ import { suite, test } from "node:test" import stripAnsi from "strip-ansi" import * as assertNoDiff from "../src/index" -suite("assertNoDiff.wordsWithSpace", function() { - test("matching data", function() { +suite("assertNoDiff.wordsWithSpace", () => { + test("matching data", () => { const data = "Jean-Luc Picard" assertNoDiff.wordsWithSpace(data, data) }) - test("mismatching data", function() { + test("mismatching data", () => { const obj1 = "Jean-Luc Picard" const obj2 = "Captain Picard" const expected = `mismatching words: ${red("Jean-Luc")}${green("Captain")}${gray(" Picard")}` - assert.throws(function() { + assert.throws(() => { assertNoDiff.wordsWithSpace(obj2, obj1) }, new Error(expected)) }) - test("extra whitespace", function() { + test("extra whitespace", () => { const obj1 = "foo bar" const obj2 = " foo bar" const expected = `mismatching words: ${green(" ")}${gray("foo bar")}` assert.throws( - function() { + () => { assertNoDiff.wordsWithSpace(obj2, obj1) }, new Error(expected), @@ -36,21 +36,21 @@ ${green(" ")}${gray("foo bar")}` ) }) - test("no expected value", function() { - assert.throws(function() { + test("no expected value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.wordsWithSpace("foo") }, new Error("AssertNoDiff: expected value not provided")) }) - test("no actual value", function() { - assert.throws(function() { + test("no actual value", () => { + assert.throws(() => { // @ts-ignore assertNoDiff.wordsWithSpace() }, new Error("AssertNoDiff: actual value not provided")) }) - test("custom error message", function() { + test("custom error message", () => { try { assertNoDiff.wordsWithSpace("one", "two", "custom message") } catch (e) { @@ -61,7 +61,7 @@ ${green(" ")}${gray("foo bar")}` throw new Error("assertNoDiff.wordsWithSpace didn't throw") }) - test("empty strings", function() { + test("empty strings", () => { assertNoDiff.wordsWithSpace("", "", "should allow diffing empty strings") }) })