2022-06-14 17:10:53 +02:00
|
|
|
import { SecureNoteType } from "@bitwarden/common/enums/secureNoteType";
|
|
|
|
import { SecureNoteData } from "@bitwarden/common/models/data/secureNoteData";
|
|
|
|
import { SecureNote } from "@bitwarden/common/models/domain/secureNote";
|
2022-04-16 17:18:12 +02:00
|
|
|
|
|
|
|
describe("SecureNote", () => {
|
|
|
|
let data: SecureNoteData;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
data = {
|
|
|
|
type: SecureNoteType.Generic,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Convert from empty", () => {
|
|
|
|
const data = new SecureNoteData();
|
|
|
|
const secureNote = new SecureNote(data);
|
|
|
|
|
|
|
|
expect(secureNote).toEqual({
|
|
|
|
type: undefined,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Convert", () => {
|
|
|
|
const secureNote = new SecureNote(data);
|
|
|
|
|
|
|
|
expect(secureNote).toEqual({
|
|
|
|
type: 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("toSecureNoteData", () => {
|
|
|
|
const secureNote = new SecureNote(data);
|
|
|
|
expect(secureNote.toSecureNoteData()).toEqual(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Decrypt", async () => {
|
|
|
|
const secureNote = new SecureNote();
|
|
|
|
secureNote.type = SecureNoteType.Generic;
|
|
|
|
|
|
|
|
const view = await secureNote.decrypt(null);
|
|
|
|
|
|
|
|
expect(view).toEqual({
|
|
|
|
type: 0,
|
|
|
|
});
|
|
|
|
});
|
2022-10-03 22:50:43 +02:00
|
|
|
|
|
|
|
describe("fromJSON", () => {
|
|
|
|
it("returns null if object is null", () => {
|
|
|
|
expect(SecureNote.fromJSON(null)).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
2022-04-16 17:18:12 +02:00
|
|
|
});
|