Skip to content

Commit 1a3effd

Browse files
committed
Other: Added test case for asJSON with arrays=true, see #597
1 parent 751a90f commit 1a3effd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/convert.js

+18
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ tape.test("convert", function(test) {
4848
test.end();
4949
});
5050

51+
test.test("called with arrays = true", function(test) {
52+
var obj = Message.create().asJSON({ arrays: true });
53+
54+
test.equal(obj.stringVal, undefined, "should not set stringVal");
55+
test.same(obj.stringRepeated, [], "should set stringRepeated");
56+
57+
test.equal(obj.uint64Val, undefined, "should not set uint64Val");
58+
test.same(obj.uint64Repeated, [], "should set uint64Repeated");
59+
60+
test.equal(obj.bytesVal, undefined, "should not set bytesVal");
61+
test.same(obj.bytesRepeated, [], "should set bytesRepeated");
62+
63+
test.equal(obj.enumVal, undefined, "should not set enumVal");
64+
test.same(obj.enumRepeated, [], "should set enumRepeated");
65+
66+
test.end();
67+
});
68+
5169
test.test("should convert", function(test) {
5270
var buf = protobuf.util.newBuffer(3);
5371
buf[0] = buf[1] = buf[2] = 49; // "111"

0 commit comments

Comments
 (0)