Skip to content

Commit

Permalink
Add synthetic constructor test (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha authored Sep 24, 2024
1 parent bc5cb98 commit 14886e8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,19 @@ suite('types', () => {
function hook(path) { paths.push(path); }
});

// via https://github.com/mtth/avsc/pull/469
test('synthetic constructor', () => {
const name = 'Foo';
const type = types.Type.forSchema([
'null',
{type: 'record', name: `test.${name}`, fields: [{name: 'id', type: 'string'}]},
]);

const data = {id: 'abc'};
const roundtripped = type.fromBuffer(type.toBuffer(data));
assert.equal(roundtripped.constructor.name, name);
assert.deepEqual(roundtripped, data);
})
});

suite('EnumType', () => {
Expand Down

0 comments on commit 14886e8

Please sign in to comment.