Compare commits

..

No commits in common. "master" and "v2.4.1" have entirely different histories.

9 changed files with 78 additions and 8 deletions

View File

@ -1,11 +1,5 @@
# 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

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartexpect",
"version": "2.4.2",
"version": "2.4.1",
"private": false,
"description": "A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.",
"main": "dist_ts/index.js",

14
scratch-alias.js Normal file
View File

@ -0,0 +1,14 @@
import * as smartexpect from './dist_ts/index.js';
const obj = { topLevel: 'hello' };
try {
smartexpect.expect(obj).toHaveProperty('topLevel');
console.log('alias toHaveProperty succeeded');
} catch(err) {
console.error('alias toHaveProperty failed:', err.message);
}
try {
smartexpect.expect(obj).not.toHaveProperty('missing');
console.log('alias not.toHaveProperty succeeded');
} catch(err) {
console.error('alias not.toHaveProperty failed:', err.message);
}

20
scratch-alias2.js Normal file
View File

@ -0,0 +1,20 @@
import * as smartexpect from './dist_ts/index.js';
console.log('script start');
const obj = { topLevel: 'hello' };
console.log('script: after obj');
console.log('script: test for alias toHaveProperty');
try {
smartexpect.expect(obj).toHaveProperty('topLevel');
console.log('alias toHaveProperty succeeded');
} catch(err) {
console.error('alias toHaveProperty failed:', err.message);
}
console.log('script: after first try');
console.log('script: test for alias not.toHaveProperty');
try {
smartexpect.expect(obj).not.toHaveProperty('missing');
console.log('alias not.toHaveProperty succeeded');
} catch(err) {
console.error('alias not.toHaveProperty failed:', err.message);
}
console.log('script end');

8
scratch-alias3.js Normal file
View File

@ -0,0 +1,8 @@
import * as smartexpect from './dist_ts/index.js';
console.log('script start');
const obj = { topLevel: 'hello' };
console.log('script: test alias toHaveProperty');
const ret = smartexpect.expect(obj).toHaveProperty('topLevel');
console.log('got ret:', ret, 'typeof', typeof ret);
console.log('ret.then?', ret && typeof (ret as any).then);
console.log('script end');

8
scratch-alias4.js Normal file
View File

@ -0,0 +1,8 @@
import * as smartexpect from './dist_ts/index.js';
console.log('script start');
const obj = { topLevel: 'hello' };
console.log('script: test alias toHaveProperty');
const ret = smartexpect.expect(obj).toHaveProperty('topLevel');
console.log('got ret:', ret, 'typeof', typeof ret);
console.log('ret.then?', ret && ret.then);
console.log('script end');

10
scratch-alias5.js Normal file
View File

@ -0,0 +1,10 @@
import * as smartexpect from './dist_ts/index.js';
console.log('start');
const obj = { topLevel: 'hello' };
try {
smartexpect.expect(obj).toHaveProperty('topLevel');
console.log('success');
} catch (e) {
console.log('caught in catch:', e, e.message);
}
console.log('end');

16
scratch.js Normal file
View 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);
}

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartexpect',
version: '2.4.2',
version: '2.4.1',
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
}