add test for object as key use case

This commit is contained in:
2025-01-29 17:07:35 -08:00
parent 7de1fd757e
commit 6f1464d55a

View File

@@ -15,4 +15,17 @@ describe("TupleKey", () => {
expect(`${tupleKey}`).toEqual("150|539"); expect(`${tupleKey}`).toEqual("150|539");
}); });
it("supports usage as key in object", () => {
const tupleKey1 = new TupleKey("1", "2");
const tupleKey2 = new TupleKey("3", "4");
const sampleObject = {
[tupleKey1.toString()]: "value1",
[tupleKey2.toString()]: "value2",
};
expect(sampleObject[tupleKey1.toString()]).toEqual("value1");
expect(sampleObject[(new TupleKey("1", "2")).toString()]).toEqual("value1");
});
}); });