-
Notifications
You must be signed in to change notification settings - Fork 944
Make Serializer tests work in browser, remove test duplication #2757
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
@@ -0,0 +1,40 @@ | |||
/** | |||
* @license | |||
* Copyright 2017 Google Inc. |
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.
2020? Also Google LLC
* Verifies full round-trip of JSON protos through ProtobufJs. | ||
*/ | ||
export function verifyProtobufJsRoundTrip(jsonValue: api.Value): void { | ||
const protobufJsEncocdedProto = ValueMessage.fromObject(jsonValue); |
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.
Typos in Encocded and Decocded.
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.
Fixed
|
||
let verifyProtobufJsRoundTrip: (jsonValue: api.Value) => void = () => {}; | ||
|
||
if (isNode()) { |
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 seems like you could just inline the definition of verifyProtobufJsRoundTrip
here. It doesn't seem like it would be useful in any other context because it hard codes the use of ValueMessage
.
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.
I put in a separate file so we could import ProtobufJs and its types using "import" instead of "require". This gives us type safety. If I included it here, I would have to rely on the d.t.s
files for these dependencies to use the types safely, without importing the actual sources (an import of ProtobufJs
here would break the build for the browser tests)..
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.
LGTM
This PR removes some of the duplicated serialization tests in FieldValue and changes the tests in serializer to run in the browser. My goal was to keep the test coverage the same, so on Node it still roundtrips through ProtobufJs.