mirror of
https://github.com/bitwarden/browser
synced 2026-01-01 16:13:27 +00:00
* introduce extension service * deprecate legacy forwarder types * eliminate repeat algorithm emissions * extend logging to preference management * align forwarder ids with vendor ids * fix duplicate policy emissions; debugging required logger enhancements ----- Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { Type } from "@bitwarden/generator-core";
|
|
|
|
import { GeneratedCredential } from ".";
|
|
|
|
describe("GeneratedCredential", () => {
|
|
describe("constructor", () => {
|
|
it("assigns credential", () => {
|
|
const result = new GeneratedCredential("example", Type.password, new Date(100));
|
|
|
|
expect(result.credential).toEqual("example");
|
|
});
|
|
|
|
it("assigns category", () => {
|
|
const result = new GeneratedCredential("example", Type.password, new Date(100));
|
|
|
|
expect(result.category).toEqual(Type.password);
|
|
});
|
|
|
|
it("passes through date parameters", () => {
|
|
const result = new GeneratedCredential("example", Type.password, new Date(100));
|
|
|
|
expect(result.generationDate).toEqual(new Date(100));
|
|
});
|
|
|
|
it("converts numeric dates to Dates", () => {
|
|
const result = new GeneratedCredential("example", Type.password, 100);
|
|
|
|
expect(result.generationDate).toEqual(new Date(100));
|
|
});
|
|
});
|
|
|
|
it("toJSON converts from a credential into a JSON object", () => {
|
|
const credential = new GeneratedCredential("example", Type.password, new Date(100));
|
|
|
|
const result = credential.toJSON();
|
|
|
|
expect(result).toEqual({
|
|
credential: "example",
|
|
category: Type.password,
|
|
generationDate: 100,
|
|
});
|
|
});
|
|
|
|
it("fromJSON converts Json objects into credentials", () => {
|
|
const jsonValue = {
|
|
credential: "example",
|
|
category: Type.password,
|
|
generationDate: 100,
|
|
};
|
|
|
|
const result = GeneratedCredential.fromJSON(jsonValue);
|
|
|
|
expect(result).toBeInstanceOf(GeneratedCredential);
|
|
expect(result).toEqual({
|
|
credential: "example",
|
|
category: Type.password,
|
|
generationDate: new Date(100),
|
|
});
|
|
});
|
|
});
|