camelCaseDave/xrm-mock

View on GitHub
src/xrm-mock/attributes/lookupattribute/lookupattribute.mock.ts

Summary

Maintainability
A
30 mins
Test Coverage
A
100%
import { LookupControlMock } from "../../controls/lookupcontrol/lookupcontrol.mock";
import { AttributeMock, IAttributeComponents } from "../attribute/attribute.mock";

export class LookupAttributeMock extends AttributeMock<LookupControlMock, Xrm.LookupValue[]>
                                 implements Xrm.Attributes.LookupAttribute {
    private static defaultComponents(components: ILookupAttributeComponents): ILookupAttributeComponents {
        if (!("isPartyList" in components)) {
            components.isPartyList = false;
        }
        components.attributeType = "lookup";
        return components;
    }

    public isPartyList: boolean;

    constructor(components: ILookupAttributeComponents) {
        super(LookupAttributeMock.defaultComponents(components));
        this.isPartyList = components.isPartyList;
    }

    public getIsPartyList(): boolean {
        return this.isPartyList;
    }
}

export interface ILookupAttributeComponents extends IAttributeComponents<LookupControlMock, Xrm.LookupValue[]> {
    isPartyList?: boolean;
}