2022-10-14 18:25:50 +02:00
|
|
|
import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-crypto-key";
|
|
|
|
import { AttachmentView } from "@bitwarden/common/models/view/attachment.view";
|
2022-08-05 00:07:24 +02:00
|
|
|
|
2022-10-03 22:50:43 +02:00
|
|
|
import { mockFromJson } from "../../utils";
|
|
|
|
|
2022-10-14 18:25:50 +02:00
|
|
|
jest.mock("@bitwarden/common/models/domain/symmetric-crypto-key");
|
2022-08-05 00:07:24 +02:00
|
|
|
|
|
|
|
describe("AttachmentView", () => {
|
|
|
|
it("fromJSON initializes nested objects", () => {
|
2022-10-03 22:50:43 +02:00
|
|
|
jest.spyOn(SymmetricCryptoKey, "fromJSON").mockImplementation(mockFromJson);
|
2022-08-05 00:07:24 +02:00
|
|
|
|
|
|
|
const actual = AttachmentView.fromJSON({
|
|
|
|
key: "encKeyB64" as any,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(actual.key).toEqual("encKeyB64_fromJSON");
|
|
|
|
});
|
|
|
|
});
|