diff options
author | Adam Cozzette <acozzette@google.com> | 2016-09-27 15:36:41 -0700 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2016-09-27 17:25:00 -0700 |
commit | c4d70123ac99ff1a0886fc7dfa492010b027210a (patch) | |
tree | bcf1dd1b91794db683348b862ca78548abcd228c /js/message_test.js | |
parent | 787f3fb16380a403c99716a23ed09cd7b9ea5b67 (diff) | |
download | protobuf-c4d70123ac99ff1a0886fc7dfa492010b027210a.tar.gz protobuf-c4d70123ac99ff1a0886fc7dfa492010b027210a.tar.bz2 protobuf-c4d70123ac99ff1a0886fc7dfa492010b027210a.zip |
Fixed references to foreign nested messages with CommonJS-style imports
A bug was causing generated JSPB code with CommonJS-style imports to
refer incorrectly to nested messages from other .proto files. The
generated code would have things like "test_pb.InnerMessage" instead of
"test_pb.OuterMessage.InnerMessage". This commit fixes the problem by
correctly taking into account any message nesting.
Diffstat (limited to 'js/message_test.js')
-rw-r--r-- | js/message_test.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/js/message_test.js b/js/message_test.js index 97c594c8..b0a0a72e 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -1040,4 +1040,18 @@ describe('Message test suite', function() { assertNan(message.getDefaultDoubleField()); }); + // Verify that we can successfully use a field referring to a nested message + // from a different .proto file. + it('testForeignNestedMessage', function() { + var msg = new proto.jspb.test.ForeignNestedFieldMessage(); + var nested = new proto.jspb.test.Deeply.Nested.Message(); + nested.setCount(5); + msg.setDeeplyNestedMessage(nested); + + // After a serialization-deserialization round trip we should get back the + // same data we started with. + var serialized = msg.serializeBinary(); + var deserialized = proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized); + assertEquals(5, deserialized.getDeeplyNestedMessage().getCount()); + }); }); |