smartexpect/test/test.propertyPath.ts

14 lines
617 B
TypeScript

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' } } };
// Existence check
smartexpect.expect(testObject).object.toHaveProperty('level1.level2.level3');
// Value check
smartexpect.expect(testObject).object.toHaveProperty('level1.level2.level3', 'value');
// Negation for missing deep property
smartexpect.expect(testObject).not.object.toHaveProperty('level1.level2.missing');
});
export default tap.start();