-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add test case for empty path #31
Conversation
4d7e45d
to
576572e
Compare
foo: 'bar', | ||
} as const | ||
|
||
// @ts-expect-error - '' is not define on the property, so it is correct that typescript throws an error here |
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.
// @ts-expect-error - '' is not define on the property, so it is correct that typescript throws an error here | |
// @ts-expect-error - '' is not defined on the object, so it is correct that typescript throws an error here |
// but as mentioned above, we still will set the value at runtime | ||
setByPath(test, '', 'bar') | ||
|
||
// @ts-expect-error - '' is not set on the property, so typescript should throw an error here |
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.
// @ts-expect-error - '' is not set on the property, so typescript should throw an error here | |
// @ts-expect-error - '' is not set on the object, so typescript should throw an error here |
// @ts-expect-error - 'foo' is not set on the property, so typescript should throw an error here | ||
// but as mentioned above, we still will set the value at runtime | ||
setByPath(test, '', 'bar') |
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.
this and the one line afterwards should rather get their own test case. The test name only implies that the access to an unset path is tested
@@ -110,6 +110,24 @@ it('returns undefined on non objects', () => { | |||
expect(getByPath(test, 'undef.baz')).toBe(undefined) | |||
}) | |||
|
|||
it('it returns undefined when accessing an unset path', () => { |
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.
it('it returns undefined when accessing an unset path', () => { | |
it('returns undefined when accessing an unset path', () => { |
Add some test cases to ensure correct handling of an empty path.