Skip to content

Commit 2dd503c

Browse files
author
Mat Jones
committed
update to use toBeNil() matcher
1 parent 5b53f2c commit 2dd503c

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

src/utilities/do-try.test.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ describe("do-try.ts", () => {
2626
// 5 assertions to be called.
2727
Do.try(workload).catch(
2828
(result?: ResultRecord<any>, error?: any) => {
29-
expect(result).not.toBeUndefined();
30-
expect(result).not.toBeNull();
29+
expect(result).not.toBeNil();
3130
expect(error).toBeUndefined();
3231
expect(result!.resultObject).toBeUndefined();
3332
expect(result!.errors).toHaveLength(1);
3433
}
3534
);
36-
expect.assertions(5);
35+
expect.assertions(4);
3736
});
3837

3938
it("When passed an async method and a Javascript error occurs, then passes along regular error", async () => {
@@ -45,12 +44,11 @@ describe("do-try.ts", () => {
4544
// Act & Assert
4645
Do.try(workload).catch(
4746
(result?: ResultRecord<any>, error?: any) => {
48-
expect(error).not.toBeNull();
49-
expect(error).not.toBeUndefined();
47+
expect(error).not.toBeNil();
5048
expect(result).toBeUndefined();
5149
}
5250
);
53-
expect.assertions(3);
51+
expect.assertions(2);
5452
});
5553

5654
it("When no errors occur, then catch handler is never called", async () => {
@@ -108,8 +106,7 @@ describe("do-try.ts", () => {
108106
const result = DoSync.try(workload).execute();
109107

110108
// Assert
111-
expect(result).not.toBeUndefined();
112-
expect(result).not.toBeNull();
109+
expect(result).not.toBeNil();
113110
expect(result).toBeInstanceOf(StubResourceRecord);
114111
});
115112

@@ -123,8 +120,7 @@ describe("do-try.ts", () => {
123120
const result = DoSync.try(workload)
124121
.catch((result?: ResultRecord<any>, error?: any) => {
125122
expect(result).toBeUndefined();
126-
expect(error).not.toBeUndefined();
127-
expect(error).not.toBeNull();
123+
expect(error).not.toBeNil();
128124
})
129125
.execute();
130126

@@ -144,8 +140,7 @@ describe("do-try.ts", () => {
144140
const result = DoSync.try(workload)
145141
.catch((result?: ResultRecord<any>, error?: any) => {
146142
expect(error).toBeUndefined();
147-
expect(result).not.toBeUndefined();
148-
expect(result).not.toBeNull();
143+
expect(result).not.toBeNil();
149144
expect(result!.resultObject).toBeUndefined();
150145
expect(result!.errors).toHaveLength(1);
151146
})

0 commit comments

Comments
 (0)