fix(Assertion): Improve toHaveProperty alias by forwarding arguments correctly for intuitive object property assertions
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartexpect',
|
||||
version: '2.4.0',
|
||||
version: '2.4.1',
|
||||
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
|
||||
}
|
||||
|
@ -355,7 +355,13 @@ export class Assertion<T = unknown, M extends TExecutionType = 'sync'> {
|
||||
public toInclude(substring: string) { return this.string.toInclude(substring); }
|
||||
public toMatch(regex: RegExp) { return this.string.toMatch(regex); }
|
||||
public toBeOneOf(values: any[]) { return this.string.toBeOneOf(values as string[]); }
|
||||
public toHaveProperty(property: string, value?: any) { return this.object.toHaveProperty(property, value); }
|
||||
public toHaveProperty(property: string, value?: any) {
|
||||
// Forward only provided arguments to object matcher to preserve argument count
|
||||
if (arguments.length === 2) {
|
||||
return this.object.toHaveProperty(property, value);
|
||||
}
|
||||
return this.object.toHaveProperty(property);
|
||||
}
|
||||
public toHaveOwnProperty(property: string, value?: any) { return this.object.toHaveOwnProperty(property, value); }
|
||||
public toMatchObject(expected: object) { return this.object.toMatchObject(expected); }
|
||||
public toBeInstanceOf(constructor: any) { return this.object.toBeInstanceOf(constructor); }
|
||||
|
Reference in New Issue
Block a user