2022-06-28 02:25:29 +02:00
|
|
|
import { UriMatchType } from "@bitwarden/common/enums/uriMatchType";
|
|
|
|
import { LoginUriView } from "@bitwarden/common/models/view/loginUriView";
|
|
|
|
|
2022-06-29 05:23:53 +02:00
|
|
|
const testValues = {
|
|
|
|
match: UriMatchType.Host,
|
|
|
|
uri: "http://example.com/login",
|
|
|
|
};
|
|
|
|
|
2022-06-28 02:25:29 +02:00
|
|
|
describe("LoginUriView", () => {
|
2022-06-29 05:23:53 +02:00
|
|
|
it("toJSON creates object for serialization", () => {
|
2022-06-28 02:25:29 +02:00
|
|
|
const uri = new LoginUriView();
|
2022-06-29 05:23:53 +02:00
|
|
|
Object.assign(uri, testValues);
|
|
|
|
|
|
|
|
const actual = uri.toJSON();
|
|
|
|
|
|
|
|
expect(actual).toEqual(testValues);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("fromJSON hydrates new view object", () => {
|
|
|
|
const actual = LoginUriView.fromJSON(testValues);
|
2022-06-28 02:25:29 +02:00
|
|
|
|
2022-06-29 05:23:53 +02:00
|
|
|
const expected = new LoginUriView();
|
|
|
|
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(LoginUriView);
|
2022-06-28 02:25:29 +02:00
|
|
|
});
|
|
|
|
});
|