Skip to content

Commit

Permalink
feat: Improve willCapture diff
Browse files Browse the repository at this point in the history
  • Loading branch information
NiGhTTraX committed Sep 24, 2023
1 parent f326954 commit 7d92ce9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/expectation/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ const willCapture = <T = unknown>(
return true;
},
toJSON: () => name ?? 'captures',
getDiff: (actual) => ({ actual, expected: actual }),
get value(): T | undefined {
return capturedValue;
},
Expand Down
12 changes: 12 additions & 0 deletions src/expectation/matcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,5 +626,17 @@ describe('It', () => {
expect(It.willCapture().toJSON()).toEqual('captures');
expect(It.willCapture('custom').toJSON()).toEqual('custom');
});

it('should print diff', () => {
expect(It.willCapture().getDiff('foo')).toEqual({
actual: 'foo',
expected: 'foo',
});

expect(It.willCapture('captor').getDiff('foo')).toEqual({
actual: 'foo',
expected: 'foo',
});
});
});
});

0 comments on commit 7d92ce9

Please sign in to comment.