From 803e503420bca9625a0f6f3339bb158d7ae05837 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Wed, 1 May 2024 14:20:12 -0400 Subject: [PATCH] Return object from calls to load() --- packages/office-addin-mock/src/officeMockObject.ts | 4 +++- packages/office-addin-mock/test/officeMockObject.test.ts | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/office-addin-mock/src/officeMockObject.ts b/packages/office-addin-mock/src/officeMockObject.ts index 81267f6b9..d50b3fd13 100644 --- a/packages/office-addin-mock/src/officeMockObject.ts +++ b/packages/office-addin-mock/src/officeMockObject.ts @@ -33,7 +33,7 @@ export class OfficeMockObject { } let properties: string[] = []; - if (propertyArgument === undefined) { + if (propertyArgument === undefined) { // an empty load call mean load all properties properties = ["*"]; } else if (typeof propertyArgument === "string") { @@ -47,6 +47,8 @@ export class OfficeMockObject { properties.forEach((property: string) => { this.loadMultipleProperties(property); }); + + return this; } /** diff --git a/packages/office-addin-mock/test/officeMockObject.test.ts b/packages/office-addin-mock/test/officeMockObject.test.ts index 19d870e21..9415cfdfd 100644 --- a/packages/office-addin-mock/test/officeMockObject.test.ts +++ b/packages/office-addin-mock/test/officeMockObject.test.ts @@ -95,6 +95,13 @@ describe("Test OfficeMockObject class", function() { assert.strictEqual(officeMock.notAProperty, undefined); }); + it("Load call with assignment", async function() { + const officeMock = new OfficeMockObject(testObject); + + const range = officeMock.range.load("color"); + await officeMock.sync(); + assert.strictEqual(range.color, "blue"); + }); it("Missing load", async function() { const officeMock = new OfficeMockObject(testObject); assert.strictEqual(officeMock.range.color, "Error, property was not loaded");