Skip to content

Commit

Permalink
add test case for shared schema with no fields (colyseus/discussions/…
Browse files Browse the repository at this point in the history
…610)
  • Loading branch information
endel committed Aug 12, 2023
1 parent e29b4d2 commit 5526c8e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/InstanceSharingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Quest>();
}

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);
});
});

0 comments on commit 5526c8e

Please sign in to comment.