Compare commits
No commits in common. "master" and "v2.4.0" have entirely different histories.
13
changelog.md
13
changelog.md
@ -1,18 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 2025-05-01 - 2.4.2 - fix(cleanup)
|
|
||||||
Remove unused scratch files
|
|
||||||
|
|
||||||
- Deleted scratch-alias.js, scratch-alias2.js, scratch-alias3.js, scratch-alias4.js, scratch-alias5.js, and scratch.js
|
|
||||||
- Clean up temporary alias and scratch test files
|
|
||||||
|
|
||||||
## 2025-04-30 - 2.4.1 - fix(Assertion)
|
|
||||||
Improve toHaveProperty alias by forwarding arguments correctly for intuitive object property assertions
|
|
||||||
|
|
||||||
- Updated the toHaveProperty method in the Assertion class to check the number of arguments and call the appropriate object matcher
|
|
||||||
- Added several scratch alias files to demonstrate and test the alias usage
|
|
||||||
- Enhanced test cases in test/propertypath to cover alias behavior
|
|
||||||
|
|
||||||
## 2025-04-30 - 2.4.0 - feat(object)
|
## 2025-04-30 - 2.4.0 - feat(object)
|
||||||
add toHaveOwnProperty method and improve property-path matching in object assertions
|
add toHaveOwnProperty method and improve property-path matching in object assertions
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartexpect",
|
"name": "@push.rocks/smartexpect",
|
||||||
"version": "2.4.2",
|
"version": "2.4.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.",
|
"description": "A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
16
scratch.js
Normal file
16
scratch.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import * as smartexpect from './dist_ts/index.js';
|
||||||
|
class Foo { constructor(){ this.foo='bar'; } }
|
||||||
|
console.log('foo in instance:', 'foo' in new Foo());
|
||||||
|
console.log('hasOwn foo:', Object.prototype.hasOwnProperty.call(new Foo(), 'foo'));
|
||||||
|
try {
|
||||||
|
smartexpect.expect(new Foo()).object.toHaveProperty('foo');
|
||||||
|
console.log('toHaveProperty passed');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('toHaveProperty failed:', err.message);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
smartexpect.expect(new Foo()).object.toHaveOwnProperty('foo');
|
||||||
|
console.log('toHaveOwnProperty passed');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('toHaveOwnProperty failed:', err.message);
|
||||||
|
}
|
@ -5,7 +5,6 @@ tap.test('toHaveProperty nested path via dot notation', async () => {
|
|||||||
const testObject = { level1: { level2: { level3: 'value' }}, publicTest: 'hi' };
|
const testObject = { level1: { level2: { level3: 'value' }}, publicTest: 'hi' };
|
||||||
|
|
||||||
smartexpect.expect(testObject).object.toHaveProperty('publicTest');
|
smartexpect.expect(testObject).object.toHaveProperty('publicTest');
|
||||||
smartexpect.expect(testObject).toHaveProperty('publicTest');
|
|
||||||
// Existence check
|
// Existence check
|
||||||
smartexpect.expect(testObject).object.toHaveProperty('level1.level2.level3');
|
smartexpect.expect(testObject).object.toHaveProperty('level1.level2.level3');
|
||||||
// Value check
|
// Value check
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartexpect',
|
name: '@push.rocks/smartexpect',
|
||||||
version: '2.4.2',
|
version: '2.4.0',
|
||||||
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
|
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
|
||||||
}
|
}
|
||||||
|
@ -355,13 +355,7 @@ export class Assertion<T = unknown, M extends TExecutionType = 'sync'> {
|
|||||||
public toInclude(substring: string) { return this.string.toInclude(substring); }
|
public toInclude(substring: string) { return this.string.toInclude(substring); }
|
||||||
public toMatch(regex: RegExp) { return this.string.toMatch(regex); }
|
public toMatch(regex: RegExp) { return this.string.toMatch(regex); }
|
||||||
public toBeOneOf(values: any[]) { return this.string.toBeOneOf(values as string[]); }
|
public toBeOneOf(values: any[]) { return this.string.toBeOneOf(values as string[]); }
|
||||||
public toHaveProperty(property: string, value?: any) {
|
public toHaveProperty(property: string, value?: any) { return this.object.toHaveProperty(property, value); }
|
||||||
// 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 toHaveOwnProperty(property: string, value?: any) { return this.object.toHaveOwnProperty(property, value); }
|
||||||
public toMatchObject(expected: object) { return this.object.toMatchObject(expected); }
|
public toMatchObject(expected: object) { return this.object.toMatchObject(expected); }
|
||||||
public toBeInstanceOf(constructor: any) { return this.object.toBeInstanceOf(constructor); }
|
public toBeInstanceOf(constructor: any) { return this.object.toBeInstanceOf(constructor); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user