Skip to content

Commit ac92126

Browse files
test: add test for serialization with unknown non primitive properties
1 parent e2c4264 commit ac92126

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/functional/serialization-deserialization.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,26 @@ describe("serialization and deserialization objects", () => {
8585
classedUsers.should.be.eql([userLike1, userLike2]);
8686
});
8787

88+
it("should successfully deserialize object with unknown nested properties ", () => {
89+
defaultMetadataStorage.clear();
90+
91+
class TestObject {
92+
prop: string;
93+
}
94+
95+
const payload = {
96+
prop: "Hi",
97+
extra: {
98+
anotherProp: "let's see how this works out!"
99+
}
100+
};
101+
102+
const result = deserialize(TestObject, JSON.stringify(payload));
103+
104+
result.should.be.instanceof(TestObject);
105+
result.prop.should.be.eql("Hi");
106+
// We should strip, but it's a breaking change
107+
// (<any>result).extra.should.be.undefined;
108+
});
109+
88110
});

0 commit comments

Comments
 (0)