Skip to content

Commit 3aecd10

Browse files
committed
New function syntax
1 parent 0162639 commit 3aecd10

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

test/chars.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ import { suite, test } from "node:test"
44
import stripAnsi from "strip-ansi"
55
import * as assertNoDiff from "../src/index"
66

7-
suite("assertNoDiff.chars()", function() {
8-
test("matching data", function() {
7+
suite("assertNoDiff.chars()", () => {
8+
test("matching data", () => {
99
const data = "Jean-Luc Picard"
1010
assertNoDiff.chars(data, data)
1111
})
1212

13-
test("mismatching data", function() {
13+
test("mismatching data", () => {
1414
const obj1 = "Jean-Luc Picard"
1515
const obj2 = "Captain Picard"
1616
const expected = `mismatching strings:
1717
1818
${red("Je")}${green("C")}${gray("a")}${green("ptai")}${gray("n")}${red("-Luc")}${gray(" Picard")}`
1919
assert.throws(
20-
function() {
20+
() => {
2121
assertNoDiff.chars(obj2, obj1)
2222
},
2323
new Error(expected)
2424
)
2525
})
2626

27-
test("no expected value", function() {
28-
assert.throws(function() {
27+
test("no expected value", () => {
28+
assert.throws(() => {
2929
// @ts-ignore: intentional call without second argument
3030
assertNoDiff.chars("foo")
3131
}, new Error("AssertNoDiff: expected value not provided"))
3232
})
3333

34-
test("no actual value", function() {
35-
assert.throws(function() {
34+
test("no actual value", () => {
35+
assert.throws(() => {
3636
// @ts-ignore: intentional call without arguments
3737
assertNoDiff.chars()
3838
}, new Error("AssertNoDiff: actual value not provided"))
3939
})
4040

41-
test("providing a custom message", function() {
41+
test("providing a custom message", () => {
4242
try {
4343
assertNoDiff.chars("one", "two", "custom message")
4444
} catch (e) {
@@ -49,7 +49,7 @@ ${red("Je")}${green("C")}${gray("a")}${green("ptai")}${gray("n")}${red("-Luc")}$
4949
throw new Error("assertNoDiff.chars didn't throw")
5050
})
5151

52-
test("diffing against empty strings", function() {
52+
test("diffing against empty strings", () => {
5353
assertNoDiff.chars("", "")
5454
})
5555
})

test/json.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { suite, test } from "node:test"
44
import stripAnsi from "strip-ansi"
55
import * as assertNoDiff from "../src/index"
66

7-
suite("assertNoDiff.json", function() {
8-
test("matching data", function() {
7+
suite("assertNoDiff.json", () => {
8+
test("matching data", () => {
99
const data = { firstName: "Jean-Luc", lastName: "Picard" }
1010
assertNoDiff.json(data, data)
1111
})
1212

13-
test("mismatching data", function() {
13+
test("mismatching data", () => {
1414
const obj1 = { firstName: "Jean-Luc", lastName: "Picard" }
1515
const obj2 = { firstName: "Captain", lastName: "Picard" }
1616
const expected = `mismatching objects:
@@ -19,28 +19,28 @@ ${gray("{\n")}${red(' "firstName": "Jean-Luc",\n')}${green(' "firstName": "Cap
1919
gray(' "lastName": "Picard"\n}')
2020
}`
2121
assert.throws(
22-
function() {
22+
() => {
2323
assertNoDiff.json(obj2, obj1)
2424
},
2525
new Error(expected)
2626
)
2727
})
2828

29-
test("no expected value", function() {
30-
assert.throws(function() {
29+
test("no expected value", () => {
30+
assert.throws(() => {
3131
// @ts-ignore
3232
assertNoDiff.json("foo")
3333
}, new Error("AssertNoDiff: expected value not provided"))
3434
})
3535

36-
test("no actual value", function() {
37-
assert.throws(function() {
36+
test("no actual value", () => {
37+
assert.throws(() => {
3838
// @ts-ignore
3939
assertNoDiff.json()
4040
}, new Error("AssertNoDiff: actual value not provided"))
4141
})
4242

43-
test("custom error message", function() {
43+
test("custom error message", () => {
4444
try {
4545
assertNoDiff.json({ a: 1 }, { a: 2 }, "custom message")
4646
} catch (e) {
@@ -51,7 +51,7 @@ ${gray("{\n")}${red(' "firstName": "Jean-Luc",\n')}${green(' "firstName": "Cap
5151
throw new Error("assertNoDiff.json didn't throw")
5252
})
5353

54-
test("diffing empty objects", function() {
54+
test("diffing empty objects", () => {
5555
assertNoDiff.json({}, {})
5656
})
5757
})

test/trimmed-lines.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { suite, test } from "node:test"
44
import stripAnsi from "strip-ansi"
55
import * as assertNoDiff from "../src/index"
66

7-
suite("assertNoDiff.trimmedLines", function() {
8-
test("matching data", function() {
7+
suite("assertNoDiff.trimmedLines", () => {
8+
test("matching data", () => {
99
const data = "Jean-Luc Picard"
1010
assertNoDiff.trimmedLines(data, data)
1111
})
1212

13-
test("matching data with surrounding whitespace", function() {
13+
test("matching data with surrounding whitespace", () => {
1414
const obj1 = "foo"
1515
const obj2 = " foo "
1616
assertNoDiff.trimmedLines(
@@ -20,33 +20,33 @@ suite("assertNoDiff.trimmedLines", function() {
2020
)
2121
})
2222

23-
test("mismatching data", function() {
23+
test("mismatching data", () => {
2424
const obj1 = "Jean-Luc\nPicard"
2525
const obj2 = "Captain\nPicard"
2626

2727
const expected = `mismatching lines:
2828
2929
${red("Jean-Luc\n")}${green("Captain\n")}${gray("Picard")}`
30-
assert.throws(function() {
30+
assert.throws(() => {
3131
assertNoDiff.trimmedLines(obj2, obj1)
3232
}, new Error(expected))
3333
})
3434

35-
test("no expected value", function() {
36-
assert.throws(function() {
35+
test("no expected value", () => {
36+
assert.throws(() => {
3737
// @ts-ignore
3838
assertNoDiff.trimmedLines("foo")
3939
}, new Error("AssertNoDiff: expected value not provided"))
4040
})
4141

42-
test("no actual value", function() {
43-
assert.throws(function() {
42+
test("no actual value", () => {
43+
assert.throws(() => {
4444
// @ts-ignore
4545
assertNoDiff.trimmedLines()
4646
}, new Error("AssertNoDiff: actual value not provided"))
4747
})
4848

49-
test("custom error message", function() {
49+
test("custom error message", () => {
5050
try {
5151
assertNoDiff.trimmedLines("one", "two", "custom message")
5252
} catch (e) {
@@ -57,7 +57,7 @@ ${red("Jean-Luc\n")}${green("Captain\n")}${gray("Picard")}`
5757
throw new Error("assertNoDiff.trimmedLines didn't throw")
5858
})
5959

60-
test("diffing empty strings", function() {
60+
test("diffing empty strings", () => {
6161
assertNoDiff.trimmedLines("", "", "should allow diffing empty strings")
6262
})
6363
})

test/words-with-space.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,53 @@ import { suite, test } from "node:test"
44
import stripAnsi from "strip-ansi"
55
import * as assertNoDiff from "../src/index"
66

7-
suite("assertNoDiff.wordsWithSpace", function() {
8-
test("matching data", function() {
7+
suite("assertNoDiff.wordsWithSpace", () => {
8+
test("matching data", () => {
99
const data = "Jean-Luc Picard"
1010
assertNoDiff.wordsWithSpace(data, data)
1111
})
1212

13-
test("mismatching data", function() {
13+
test("mismatching data", () => {
1414
const obj1 = "Jean-Luc Picard"
1515
const obj2 = "Captain Picard"
1616
const expected = `mismatching words:
1717
1818
${red("Jean-Luc")}${green("Captain")}${gray(" Picard")}`
19-
assert.throws(function() {
19+
assert.throws(() => {
2020
assertNoDiff.wordsWithSpace(obj2, obj1)
2121
}, new Error(expected))
2222
})
2323

24-
test("extra whitespace", function() {
24+
test("extra whitespace", () => {
2525
const obj1 = "foo bar"
2626
const obj2 = " foo bar"
2727
const expected = `mismatching words:
2828
2929
${green(" ")}${gray("foo bar")}`
3030
assert.throws(
31-
function() {
31+
() => {
3232
assertNoDiff.wordsWithSpace(obj2, obj1)
3333
},
3434
new Error(expected),
3535
"should not tolerate surrounding whitespace"
3636
)
3737
})
3838

39-
test("no expected value", function() {
40-
assert.throws(function() {
39+
test("no expected value", () => {
40+
assert.throws(() => {
4141
// @ts-ignore
4242
assertNoDiff.wordsWithSpace("foo")
4343
}, new Error("AssertNoDiff: expected value not provided"))
4444
})
4545

46-
test("no actual value", function() {
47-
assert.throws(function() {
46+
test("no actual value", () => {
47+
assert.throws(() => {
4848
// @ts-ignore
4949
assertNoDiff.wordsWithSpace()
5050
}, new Error("AssertNoDiff: actual value not provided"))
5151
})
5252

53-
test("custom error message", function() {
53+
test("custom error message", () => {
5454
try {
5555
assertNoDiff.wordsWithSpace("one", "two", "custom message")
5656
} catch (e) {
@@ -61,7 +61,7 @@ ${green(" ")}${gray("foo bar")}`
6161
throw new Error("assertNoDiff.wordsWithSpace didn't throw")
6262
})
6363

64-
test("empty strings", function() {
64+
test("empty strings", () => {
6565
assertNoDiff.wordsWithSpace("", "", "should allow diffing empty strings")
6666
})
6767
})

0 commit comments

Comments
 (0)