@itwin/presentation-testing
Version:
Testing utilities for iTwin.js Presentation library
93 lines • 4.02 kB
TypeScript
/** @packageDocumentation
* @module Content
*/
import { PropertyRecord } from "@itwin/appui-abstract";
import { IModelConnection } from "@itwin/core-frontend";
import { Content, InstanceKey, KeySet, PageOptions, Ruleset } from "@itwin/presentation-common";
/**
* Interface for a data provider, which is used by ContentBuilder.
* @public
*/
export interface IContentBuilderDataProvider {
/** Keys the data provider is creating content for */
keys: Readonly<KeySet>;
/** Get the size of content result set */
getContentSetSize: () => Promise<number>;
/** Get the content */
getContent: (options?: PageOptions) => Promise<Readonly<Content> | undefined>;
}
/**
* Property records grouped under a single className
* @public
*/
export interface ContentBuilderResult {
/** Full name of ECClass whose records are contained in this data structure */
className: string;
/** Property records for the ECClass instance */
records: PropertyRecord[];
}
/**
* Properties for creating a `ContentBuilder` instance.
* @public
*/
export interface ContentBuilderProps {
/** The iModel to pull data from */
imodel: IModelConnection;
/** Custom data provider that allows mocking data ContentBuilder receives */
dataProvider?: IContentBuilderDataProvider;
/**
* Decimal precision or numeric types.
*
* Raw numeric values with high precision may slightly differ from platform to platform due to
* rounding differences on different platforms. This may be a problem when used with snapshot testing,
* in which case this attribute may be set to supply the maximum precision of raw numeric values.
*
* By default no rounding is applied.
*/
decimalPrecision?: number;
}
/**
* A class that constructs content from specified imodel and ruleset.
* @public
*/
export declare class ContentBuilder {
private readonly _iModel;
private _dataProvider;
private _decimalPrecision?;
/**
* Constructor
* @param iModel
* @param dataProvider
*/
constructor(props: ContentBuilderProps);
private doCreateContent;
/**
* Create a list of property records using the supplied presentation ruleset.
* @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.
* @param instanceKeys Keys of instances that should be queried.
* @param displayType Type of content container display. For example:
* "PropertyPane", "Grid", "List" etc.
*/
createContent(rulesetOrId: Ruleset | string, instanceKeys: InstanceKey[], displayType?: string): Promise<PropertyRecord[]>;
private getECClassNames;
private createContentForClasses;
/**
* Create a list of grouped property records using the supplied presentation ruleset.
* Each group includes all of the class instances.
* @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.
* @param displayType Type of content container display. For example:
* "PropertyPane", "Grid", "List" etc.
* @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.
*/
createContentForAllInstances(rulesetOrId: Ruleset | string, displayType?: string): Promise<ContentBuilderResult[]>;
/**
* Create a list of grouped property records using the supplied presentation ruleset.
* Each group includes at most one class instance.
* @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.
* @param displayType Type of content container display. For example:
* "PropertyPane", "Grid", "List" etc.
* @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.
*/
createContentForInstancePerClass(rulesetOrId: Ruleset | string, displayType?: string): Promise<ContentBuilderResult[]>;
}
//# sourceMappingURL=ContentBuilder.d.ts.map