2022-06-14 17:10:53 +02:00
|
|
|
import { SendTextData } from "@bitwarden/common/models/data/sendTextData";
|
|
|
|
import { SendText } from "@bitwarden/common/models/domain/sendText";
|
2022-04-16 17:18:12 +02:00
|
|
|
|
2022-08-05 00:07:24 +02:00
|
|
|
import { mockEnc } from "../../utils";
|
2022-04-16 17:18:12 +02:00
|
|
|
|
|
|
|
describe("SendText", () => {
|
|
|
|
let data: SendTextData;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
data = {
|
|
|
|
text: "encText",
|
|
|
|
hidden: false,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Convert from empty", () => {
|
|
|
|
const data = new SendTextData();
|
|
|
|
const secureNote = new SendText(data);
|
|
|
|
|
|
|
|
expect(secureNote).toEqual({
|
|
|
|
hidden: undefined,
|
|
|
|
text: null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Convert", () => {
|
|
|
|
const secureNote = new SendText(data);
|
|
|
|
|
|
|
|
expect(secureNote).toEqual({
|
|
|
|
hidden: false,
|
|
|
|
text: { encryptedString: "encText", encryptionType: 0 },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Decrypt", async () => {
|
|
|
|
const secureNote = new SendText();
|
|
|
|
secureNote.text = mockEnc("text");
|
|
|
|
secureNote.hidden = true;
|
|
|
|
|
|
|
|
const view = await secureNote.decrypt(null);
|
|
|
|
|
|
|
|
expect(view).toEqual({
|
|
|
|
text: "text",
|
|
|
|
hidden: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|