1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Add a key definition for providers (#7915)

This commit is contained in:
Addison Beck 2024-02-13 06:27:52 -06:00 committed by GitHub
parent b64650ad9e
commit a9297af2d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import { ProviderUserStatusType, ProviderUserType } from "../enums";
import { ProviderData } from "../models/data/provider.data";
import { PROVIDERS } from "./provider.service";
describe("PROVIDERS key definition", () => {
const sut = PROVIDERS;
it("should deserialize to a proper ProviderData object", async () => {
const expectedResult: Record<string, ProviderData> = {
"1": {
id: "string",
name: "string",
status: ProviderUserStatusType.Accepted,
type: ProviderUserType.ServiceUser,
enabled: true,
userId: "string",
useEvents: true,
},
};
const result = sut.deserializer(JSON.parse(JSON.stringify(expectedResult)));
expect(result).toEqual(expectedResult);
});
});

View File

@ -1,8 +1,13 @@
import { StateService } from "../../platform/abstractions/state.service";
import { KeyDefinition, PROVIDERS_DISK } from "../../platform/state";
import { ProviderService as ProviderServiceAbstraction } from "../abstractions/provider.service";
import { ProviderData } from "../models/data/provider.data";
import { Provider } from "../models/domain/provider";
export const PROVIDERS = KeyDefinition.record<ProviderData>(PROVIDERS_DISK, "providers", {
deserializer: (obj: ProviderData) => obj,
});
export class ProviderService implements ProviderServiceAbstraction {
constructor(private stateService: StateService) {}