2022-08-05 00:07:24 +02:00
|
|
|
import { LoginUriView } from "@bitwarden/common/models/view/loginUriView";
|
|
|
|
import { LoginView } from "@bitwarden/common/models/view/loginView";
|
|
|
|
|
2022-10-03 22:50:43 +02:00
|
|
|
import { mockFromJson } from "../../utils";
|
|
|
|
|
2022-08-05 00:07:24 +02:00
|
|
|
jest.mock("@bitwarden/common/models/view/loginUriView");
|
|
|
|
|
|
|
|
describe("LoginView", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
(LoginUriView as any).mockClear();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("fromJSON initializes nested objects", () => {
|
2022-10-03 22:50:43 +02:00
|
|
|
jest.spyOn(LoginUriView, "fromJSON").mockImplementation(mockFromJson);
|
2022-08-05 00:07:24 +02:00
|
|
|
|
|
|
|
const passwordRevisionDate = new Date();
|
|
|
|
|
|
|
|
const actual = LoginView.fromJSON({
|
|
|
|
passwordRevisionDate: passwordRevisionDate.toISOString(),
|
|
|
|
uris: ["uri1", "uri2", "uri3"] as any,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(actual).toMatchObject({
|
|
|
|
passwordRevisionDate: passwordRevisionDate,
|
|
|
|
uris: ["uri1_fromJSON", "uri2_fromJSON", "uri3_fromJSON"],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|