From 5526c8ea507d1f7c10b43595c26f165cbc36729e Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Sat, 12 Aug 2023 11:14:57 -0300 Subject: [PATCH] add test case for shared schema with no fields (colyseus/discussions/610) --- test/InstanceSharingTest.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/InstanceSharingTest.ts b/test/InstanceSharingTest.ts index 6f8ec9b9..841081bb 100644 --- a/test/InstanceSharingTest.ts +++ b/test/InstanceSharingTest.ts @@ -211,4 +211,23 @@ describe("Instance sharing", () => { "all refCount's should have a valid number." ); }); + + it("should allow having shared Schema class with no fields", () => { + class Quest extends Schema {} + class QuestOne extends Quest { + @type("string") name: string; + } + + class State extends Schema { + @type({map: Quest}) quests = new MapSchema(); + } + + const state = new State(); + state.quests.set('one', new QuestOne().assign({ name: "one" })); + + const decodedState = new State(); + decodedState.decode(state.encode()); + + assert.strictEqual("one", (decodedState.quests.get('one') as QuestOne).name); + }); }); \ No newline at end of file