-
Notifications
You must be signed in to change notification settings - Fork 257
test(NODE-6438): check that BSON undefined is returned from deserialize #721
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
Conversation
test/node/bson_undefined.test.ts
Outdated
describe('when serialize is given a javascript object that contains undefined', () => { | ||
describe('when ignoreUndefined is set to false', function () { | ||
it('serializes to document with a set to BSON null (type=10)', () => { | ||
const jsObject = BSON.deserialize(bsonDocWithUndefined); |
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.
const jsObject = BSON.deserialize(bsonDocWithUndefined); | |
const jsObject = { a: undefined }; |
Is there a reason we can't use an object literal?
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.
good point, fixed
test/node/bson_undefined.test.ts
Outdated
const jsObject = BSON.deserialize(bsonDocWithUndefined); | ||
const bytes = BSON.serialize(jsObject, { ignoreUndefined: false }); | ||
expect(bytes).to.have.lengthOf(8); | ||
expect(bytes).to.have.own.property('4', BSON_DATA_NULL); |
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.
What is happening in this assertion? Does haveOwnProperty
check for index access if the object is a Buffer?
Could we use parseToElementsToArray to re-parse the serialized bytes and confirm the serialized bytes contain one BSON null?
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.
good use of parseToElements
Description
What is changing?
Is there new documentation needed for these changes?
Yes
What is the motivation for this change?
I noticed no test fails if I change
BSON_DATA_UNDEFINED
handling, seems worthy of coverage given how the serializer special cases that same value.Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript