feat(object): add toHaveOwnProperty method and improve property-path matching in object assertions

This commit is contained in:
2025-04-30 18:24:28 +00:00
parent 0d3d498240
commit 0351da2878
7 changed files with 39 additions and 4 deletions

View File

@ -2,7 +2,9 @@ import { tap, expect as tExpect } from '@push.rocks/tapbundle';
import * as smartexpect from '../dist_ts/index.js';
tap.test('toHaveProperty nested path via dot notation', async () => {
const testObject = { level1: { level2: { level3: 'value' } } };
const testObject = { level1: { level2: { level3: 'value' }}, publicTest: 'hi' };
smartexpect.expect(testObject).object.toHaveProperty('publicTest');
// Existence check
smartexpect.expect(testObject).object.toHaveProperty('level1.level2.level3');
// Value check
@ -11,4 +13,4 @@ tap.test('toHaveProperty nested path via dot notation', async () => {
smartexpect.expect(testObject).not.object.toHaveProperty('level1.level2.missing');
});
export default tap.start();
export default tap.start();