Skip to content

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

Merged
merged 3 commits into from
Mar 18, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Mar 17, 2020

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.

@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2017 Google Inc.
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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()) {
Copy link
Contributor

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.

Copy link
Contributor Author

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)..

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Mar 18, 2020
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@schmidt-sebastian schmidt-sebastian merged commit 60e9f4a into master Mar 18, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/serializertest branch March 26, 2020 03:05
@firebase firebase locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants