Skip to content

Commit e7294ce

Browse files
committed
Add test for reading JS property from prototype
1 parent 200d736 commit e7294ce

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/JSInterop/Microsoft.JSInterop.JS/src/test/CallDispatcher.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ describe("CallDispatcher", () => {
197197
expect(result).toBe("20");
198198
});
199199

200+
test("GetValue: Property defined on prototype is retrieved", () => {
201+
const grandParentPrototype = { a: 30 };
202+
const parentPrototype = Object.create(grandParentPrototype);
203+
const testObject = Object.create(parentPrototype);
204+
const objectId = getObjectReferenceId(testObject);
205+
206+
const invocationInfo: DotNet.JSInvocationInfo = {
207+
asyncHandle: 0,
208+
targetInstanceId: objectId,
209+
identifier: "a",
210+
callType: DotNet.JSCallType.GetValue,
211+
resultType: DotNet.JSCallResultType.Default,
212+
argsJson: null
213+
};
214+
215+
const result = dispatcher.invokeJSFromDotNet(invocationInfo);
216+
217+
expect(result).toBe("30");
218+
});
219+
200220
test("GetValue: Reading undefined property throws", () => {
201221
const testObject = { a: 10 };
202222
const objectId = getObjectReferenceId(testObject);
@@ -231,7 +251,7 @@ describe("CallDispatcher", () => {
231251
expect(result).toMatch("__jsObjectId");
232252
});
233253

234-
test("GetValue: Object value is retrieved from reference and empty identifier", () => {
254+
test("GetValue: Object value is retrieved from reference with empty identifier", () => {
235255
const testObject = { a: { b: 20 } };
236256
const objectId = getObjectReferenceId(testObject);
237257

0 commit comments

Comments
 (0)