aboutsummaryrefslogtreecommitdiffhomepage
path: root/js/message_test.js
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2017-03-06 15:12:19 -0800
committerGravatar Adam Cozzette <acozzette@google.com>2017-03-06 15:37:40 -0800
commit651ba62ab5a9c35e157380e2fd89cf77febb47b9 (patch)
tree2aa83e2d2ac475a1b74132b9a07a82dba67f752e /js/message_test.js
parent008ff033ef3308512c1da2b7cdadf50a6296251a (diff)
JS: ensure that extension values are serialized even if they're falsy
There was a bug where for JavaScript we would only serialize an extension value if it evaluated as truthy, which meant that values like 0 would get silently dropped (even in proto2, where field presence is significant). This fixes issue #2605, and takes care of the output of toObject() in addition to the binary format.
Diffstat (limited to 'js/message_test.js')
-rw-r--r--js/message_test.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/js/message_test.js b/js/message_test.js
index a2c5763d..2298742d 100644
--- a/js/message_test.js
+++ b/js/message_test.js
@@ -693,10 +693,11 @@ describe('Message test suite', function() {
});
it('testToObject_hasExtensionField', function() {
- var data = new proto.jspb.test.HasExtensions(['str1', {100: ['ext1']}]);
+ var data = new proto.jspb.test.HasExtensions(['str1', {100: ['ext1'], 102: ''}]);
var obj = data.toObject();
assertEquals('str1', obj.str1);
assertEquals('ext1', obj.extField.ext1);
+ assertEquals('', obj.str);
});
it('testGetExtension', function() {