diff --git a/libs/common/src/key-management/models/response/user-decryption.response.spec.ts b/libs/common/src/key-management/models/response/user-decryption.response.spec.ts index 5a5a2a26b2e..20596a75ef2 100644 --- a/libs/common/src/key-management/models/response/user-decryption.response.spec.ts +++ b/libs/common/src/key-management/models/response/user-decryption.response.spec.ts @@ -35,9 +35,14 @@ describe("UserDecryptionResponse", () => { ); }); - it("should create response when masterPasswordUnlock is not provided", () => { - const userDecryptionResponse = new UserDecryptionResponse({}); + it.each([null, undefined, "should be object type"])( + "should create response when masterPasswordUnlock is %s", + (masterPasswordUnlock) => { + const userDecryptionResponse = new UserDecryptionResponse({ + MasterPasswordUnlock: masterPasswordUnlock, + }); - expect(userDecryptionResponse.masterPasswordUnlock).toBeUndefined(); - }); + expect(userDecryptionResponse.masterPasswordUnlock).toBeUndefined(); + }, + ); }); diff --git a/libs/common/src/key-management/models/response/user-decryption.response.ts b/libs/common/src/key-management/models/response/user-decryption.response.ts index 0ef4e014fe6..b3ac5b80b32 100644 --- a/libs/common/src/key-management/models/response/user-decryption.response.ts +++ b/libs/common/src/key-management/models/response/user-decryption.response.ts @@ -8,7 +8,7 @@ export class UserDecryptionResponse extends BaseResponse { super(response); const masterPasswordUnlock = this.getResponseProperty("MasterPasswordUnlock"); - if (masterPasswordUnlock != null || typeof masterPasswordUnlock === "object") { + if (masterPasswordUnlock != null && typeof masterPasswordUnlock === "object") { this.masterPasswordUnlock = new MasterPasswordUnlockResponse(masterPasswordUnlock); } }