-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove void return type for propertyDiff() #189
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR! ❤️
Could you add a test to make sure this stays working as intended after this PR? Something in typescript.test.ts
that just makes sure void isn't the return type or value.
Do you think this would require a major version bump according to semver?
Hey @maritz, |
test.serial( | ||
'return type', | ||
async (t) => { | ||
const testInstance = await nohm.factory<UserMockup>('UserMockup'); | ||
const diffBeforeUpdate = testInstance.propertyDiff('name'); | ||
|
||
// update the property | ||
testInstance.property('name','testName'); | ||
const diffAfterUpdate = testInstance.propertyDiff('name'); | ||
|
||
t.deepEqual(diffBeforeUpdate, [], 'return without undefined'); | ||
t.deepEqual(diffAfterUpdate, [{ | ||
after: 'testName', | ||
before: 'defaultName', | ||
key: 'name', | ||
}], 'return with difference in property'); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I think this test would not have failed previously, right? The only real change is the return type of an item inside the array. So you'd have to make a test that loops over the diff and explicitly tries to access an item in it.
Something like
diffBeforeUpdate.forEach((diffItem) => {
// should never be called, but also shouldn't cause a TS error
console.log('diff had item', diffItem);
t.fail('should never reach this');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, the resultant from the earlier version was returning [undefined]
(as the JS func which doesn't return anything is undefined for return), and hence this test would have failed for deepEquals when compared with []
on the previous version. Happy to make change if that's not the case here
Yeah, I was thinking so as well. I'm kind of hesitant to just publish a v3 only for this rather minimal change. But on the other hand I can't really promise when other bigger changes are coming. I guess I'll add this and some dependency updates into a v3 soon and not hold it up for other stuff. |
for issue #186
onePropertyDiff
return value, so as to return empty array from propertyDiff.