2022-06-28 01:42:35 +02:00
|
|
|
import { UriMatchType } from "@bitwarden/common/enums/uriMatchType";
|
2022-06-28 02:28:26 +02:00
|
|
|
import { AttachmentView } from "@bitwarden/common/models/view/attachmentView";
|
2022-06-28 01:42:35 +02:00
|
|
|
import { CipherView } from "@bitwarden/common/models/view/cipherView";
|
|
|
|
import { LoginUriView } from "@bitwarden/common/models/view/loginUriView";
|
|
|
|
|
|
|
|
|
2022-06-28 02:28:26 +02:00
|
|
|
jest.mock("@bitwarden/common/models/view/attachmentView");
|
2022-06-28 01:42:35 +02:00
|
|
|
|
|
|
|
const primitiveFields = {
|
|
|
|
id: "myId",
|
|
|
|
folderId: "folderId",
|
|
|
|
organizationId: "organizationId",
|
|
|
|
};
|
|
|
|
|
|
|
|
describe("CipherView", () => {
|
|
|
|
let cipherView: CipherView;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
(AttachmentView as any).mockClear();
|
|
|
|
|
|
|
|
cipherView = new CipherView();
|
|
|
|
Object.assign(cipherView, primitiveFields);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("serializes", () => {
|
|
|
|
// cipherView.attachments = [new AttachmentView(), new AttachmentView()];
|
|
|
|
|
|
|
|
// const actual = JSON.stringify(cipherView);
|
|
|
|
|
|
|
|
// expect(cipherView.attachments[0].toJSON).toHaveBeenCalledTimes(1);
|
|
|
|
// expect(cipherView.attachments[1].toJSON).toHaveBeenCalledTimes(1);
|
|
|
|
|
|
|
|
// expect(actual).toEqual(JSON.stringify(primitiveFields));
|
|
|
|
|
|
|
|
const uri = new LoginUriView();
|
|
|
|
uri.match = UriMatchType.Domain;
|
|
|
|
uri.uri = "test";
|
|
|
|
|
|
|
|
const parsed = JSON.parse(JSON.stringify(uri));
|
|
|
|
expect(parsed).toEqual({
|
|
|
|
match: UriMatchType.Domain,
|
|
|
|
uri: "test",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// it("deserializes", () => {
|
|
|
|
|
|
|
|
// const stringify = JSON.stringify(cipherView);
|
|
|
|
// const actual = CipherView.fromJSON(stringify)
|
|
|
|
// expect(actual).toEqual(primitiveFields)
|
|
|
|
// });
|
|
|
|
});
|