diff --git a/libs/common/spec/models/domain/symmetricCryptoKey.spec.ts b/libs/common/spec/models/domain/symmetricCryptoKey.spec.ts index e0c147dfc9..5670fe4699 100644 --- a/libs/common/spec/models/domain/symmetricCryptoKey.spec.ts +++ b/libs/common/spec/models/domain/symmetricCryptoKey.spec.ts @@ -67,13 +67,20 @@ describe("SymmetricCryptoKey", () => { }); }); - it("serializes and deserializes", () => { + it("toJSON creates object for serialization", () => { const key = new SymmetricCryptoKey(makeStaticByteArray(64).buffer); - const serialized = JSON.stringify(key); + const actual = key.toJSON(); - const newKey = SymmetricCryptoKey.fromJSON(JSON.parse(serialized)); + const expected = { keyB64: key.keyB64 }; - expect(newKey).toEqual(key); - expect(newKey).toBeInstanceOf(SymmetricCryptoKey); + expect(actual).toEqual(expected); + }); + + it("fromJSON hydrates new object", () => { + const expected = new SymmetricCryptoKey(makeStaticByteArray(64).buffer); + const actual = SymmetricCryptoKey.fromJSON({ keyB64: expected.keyB64 }); + + expect(actual).toEqual(expected); + expect(actual).toBeInstanceOf(SymmetricCryptoKey); }); }); diff --git a/libs/common/spec/models/view/cipherView.spec.ts b/libs/common/spec/models/view/cipherView.spec.ts index 51634021d2..cdf458976d 100644 --- a/libs/common/spec/models/view/cipherView.spec.ts +++ b/libs/common/spec/models/view/cipherView.spec.ts @@ -46,7 +46,9 @@ describe("CipherView", () => { const cipher = new CipherView(); Object.assign(cipher, testValues); - expect(cipher.toJSON()).toEqual(testValues); + const actual = cipher.toJSON(); + + expect(actual).toEqual(testValues); }); it("fromJSON hydrates new view object", () => { @@ -56,8 +58,8 @@ describe("CipherView", () => { jest.spyOn(FieldView, "fromJSON").mockImplementation(mockFromJson); jest.spyOn(PasswordHistoryView, "fromJSON").mockImplementation(mockFromJson); - const parsedObject = JSON.parse(JSON.stringify(testValues)); - const actual = CipherView.fromJSON(parsedObject); + const parsed = JSON.parse(JSON.stringify(testValues)); + const actual = CipherView.fromJSON(parsed); const expected = new CipherView(); Object.assign(expected, testValues, { diff --git a/libs/common/spec/models/view/loginView.spec.ts b/libs/common/spec/models/view/loginView.spec.ts index 61ec3794e1..fed9a3700c 100644 --- a/libs/common/spec/models/view/loginView.spec.ts +++ b/libs/common/spec/models/view/loginView.spec.ts @@ -18,15 +18,13 @@ describe("LoginView", () => { }); it("fromJSON hydrates new view object", () => { - const parsedFromJson = { - ...testValues, - passwordRevisionDate: testValues.passwordRevisionDate.toISOString(), - }; + const parsed = JSON.parse(JSON.stringify(testValues)); + jest .spyOn(LoginUriView, "fromJSON") .mockImplementation((key: string) => (key + "fromJSON") as any); - const login = LoginView.fromJSON(parsedFromJson); + const login = LoginView.fromJSON(parsed); expect(login).toEqual({ ...testValues,