Skip to content

Commit

Permalink
Swap got and expected parameters in order to fix diff reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHreben committed Oct 9, 2020
1 parent 91bab60 commit f7cb331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ export function toMatchError(
if (got.class !== expected.class) {
diff.push(
"Error class is not the same:",
this.utils.diff(got.class, expected.class) as string
this.utils.diff(expected.class, got.class) as string
);
}

if (got.message !== expected.message) {
diff.push(
"Error message is not the same:",
this.utils.diff(got.message, expected.message) as string
this.utils.diff(expected.message, got.message) as string
);
}

if (!this.equals(got.publicFields, expected.publicFields)) {
if (!this.equals(expected.publicFields, got.publicFields)) {
diff.push(
"Error public fields is not the same:",
this.utils.diff(got.publicFields, expected.publicFields) as string
this.utils.diff(expected.publicFields, got.publicFields) as string
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/matcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe("matcher", () => {
- Expected
+ Received
- [Function SpecificError2]
+ [Function SpecificError]"
- [Function SpecificError]
+ [Function SpecificError2]"
`);
});

Expand All @@ -51,8 +51,8 @@ describe("matcher", () => {
- Expected
+ Received
- test
+ test2"
- test2
+ test"
`);
});

Expand All @@ -67,8 +67,8 @@ describe("matcher", () => {
+ Received
Object {
- "other": Object {},
+ "other": false,
- "other": false,
+ "other": Object {},
}"
`);
});
Expand Down Expand Up @@ -99,8 +99,8 @@ describe("matcher", () => {
- Expected
+ Received
- [Function SpecificError]
+ [Function SpecificError2]"
- [Function SpecificError2]
+ [Function SpecificError]"
`);
});
});
Expand Down

0 comments on commit f7cb331

Please sign in to comment.