bitwarden-estensione-browser/libs/common/spec/models/view/identityView.spec.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-06-28 02:25:29 +02:00
import { IdentityView } from "@bitwarden/common/models/view/identityView";
2022-06-29 05:23:53 +02:00
const testValues = {
title: "Mr",
firstName: "First",
middleName: "Middle",
lastName: "Last",
address1: "123",
address2: "Fake St",
address3: "Business Park",
city: "Sydney",
state: "NSW",
postalCode: "2000",
country: "Australia",
company: "Bitwarden",
email: "example@ex.com",
phone: "1234",
ssn: "09876",
username: "myUsername0",
passportNumber: "A12387",
licenseNumber: "asdf",
};
2022-06-28 02:25:29 +02:00
describe("IdentityView", () => {
2022-06-29 05:23:53 +02:00
it("toJSON creates object for serialization", () => {
2022-06-28 02:25:29 +02:00
const identity = new IdentityView();
2022-06-29 05:23:53 +02:00
Object.assign(identity, testValues);
const actual = identity.toJSON();
expect(actual).toEqual(testValues);
});
it("fromJSON hydrates new view object", () => {
const actual = IdentityView.fromJSON(testValues);
2022-06-28 02:25:29 +02:00
2022-06-29 05:23:53 +02:00
const expected = new IdentityView();
Object.assign(expected, testValues);
2022-06-28 02:25:29 +02:00
2022-06-29 05:23:53 +02:00
expect(actual).toEqual(expected);
expect(actual).toBeInstanceOf(IdentityView);
2022-06-28 02:25:29 +02:00
});
});