Add a key definition for providers (#7915)
This commit is contained in:
parent
b64650ad9e
commit
a9297af2d3
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue