@itwin/presentation-testing 4.0.0-dev.6 → 4.0.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +927 -959
- package/LICENSE.md +9 -9
- package/README.md +7 -7
- package/lib/cjs/presentation-testing/ContentBuilder.d.ts +92 -89
- package/lib/cjs/presentation-testing/ContentBuilder.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/ContentBuilder.js +178 -149
- package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.d.ts +45 -42
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +138 -139
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +69 -66
- package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/HierarchyBuilder.js +78 -67
- package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts +46 -46
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.js +83 -77
- package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -1
- package/lib/cjs/presentation-testing.d.ts +28 -28
- package/lib/cjs/presentation-testing.d.ts.map +1 -1
- package/lib/cjs/presentation-testing.js +44 -44
- package/lib/cjs/presentation-testing.js.map +1 -1
- package/lib/esm/presentation-testing/ContentBuilder.d.ts +92 -89
- package/lib/esm/presentation-testing/ContentBuilder.d.ts.map +1 -1
- package/lib/esm/presentation-testing/ContentBuilder.js +174 -145
- package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts +45 -42
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +113 -114
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +69 -66
- package/lib/esm/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
- package/lib/esm/presentation-testing/HierarchyBuilder.js +73 -62
- package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.d.ts +46 -46
- package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.js +75 -69
- package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -1
- package/lib/esm/presentation-testing.d.ts +28 -28
- package/lib/esm/presentation-testing.d.ts.map +1 -1
- package/lib/esm/presentation-testing.js +32 -32
- package/lib/esm/presentation-testing.js.map +1 -1
- package/package.json +53 -53
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module IModel
|
|
3
|
-
*/
|
|
4
|
-
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
-
import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps } from "@itwin/core-common";
|
|
7
|
-
import { IModelConnection } from "@itwin/core-frontend";
|
|
8
|
-
/**
|
|
9
|
-
* Interface for IModel builder pattern. Used for building IModels to test rulesets.
|
|
10
|
-
*
|
|
11
|
-
* @beta
|
|
12
|
-
*/
|
|
13
|
-
export interface TestIModelBuilder {
|
|
14
|
-
/** Insert a model into the builder's iModel */
|
|
15
|
-
insertModel<TProps extends ModelProps>(props: TProps): Id64String;
|
|
16
|
-
/** Insert an element into the builder's iModel */
|
|
17
|
-
insertElement<TProps extends ElementProps>(props: TProps): Id64String;
|
|
18
|
-
/** Insert an element aspect into the specified element */
|
|
19
|
-
insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
|
|
20
|
-
/**
|
|
21
|
-
* Create code for specified element.
|
|
22
|
-
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
23
|
-
*/
|
|
24
|
-
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Function that creates an iModel and returns a connection to it.
|
|
28
|
-
* @param name Name of test IModel
|
|
29
|
-
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
30
|
-
*
|
|
31
|
-
* @beta
|
|
32
|
-
*/
|
|
33
|
-
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
34
|
-
/**
|
|
35
|
-
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
export declare class IModelBuilder implements TestIModelBuilder {
|
|
40
|
-
private _iModel;
|
|
41
|
-
constructor(iModel: IModelDb);
|
|
42
|
-
insertModel<TProps extends ModelProps>(props: TProps): Id64String;
|
|
43
|
-
insertElement<TProps extends ElementProps>(props: TProps): Id64String;
|
|
44
|
-
insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
|
|
45
|
-
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
46
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module IModel
|
|
3
|
+
*/
|
|
4
|
+
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps } from "@itwin/core-common";
|
|
7
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
8
|
+
/**
|
|
9
|
+
* Interface for IModel builder pattern. Used for building IModels to test rulesets.
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export interface TestIModelBuilder {
|
|
14
|
+
/** Insert a model into the builder's iModel */
|
|
15
|
+
insertModel<TProps extends ModelProps>(props: TProps): Id64String;
|
|
16
|
+
/** Insert an element into the builder's iModel */
|
|
17
|
+
insertElement<TProps extends ElementProps>(props: TProps): Id64String;
|
|
18
|
+
/** Insert an element aspect into the specified element */
|
|
19
|
+
insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
|
|
20
|
+
/**
|
|
21
|
+
* Create code for specified element.
|
|
22
|
+
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
23
|
+
*/
|
|
24
|
+
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Function that creates an iModel and returns a connection to it.
|
|
28
|
+
* @param name Name of test IModel
|
|
29
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
30
|
+
*
|
|
31
|
+
* @beta
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
34
|
+
/**
|
|
35
|
+
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare class IModelBuilder implements TestIModelBuilder {
|
|
40
|
+
private _iModel;
|
|
41
|
+
constructor(iModel: IModelDb);
|
|
42
|
+
insertModel<TProps extends ModelProps>(props: TProps): Id64String;
|
|
43
|
+
insertElement<TProps extends ElementProps>(props: TProps): Id64String;
|
|
44
|
+
insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
|
|
45
|
+
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
46
|
+
}
|
|
47
47
|
//# sourceMappingURL=IModelUtilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAY,kBAAkB,EAAE,YAAY,EAAiB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC9I,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAG5E;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAClE,kDAAkD;IAClD,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACtE,0DAA0D;IAC1D,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrE;;;OAGG;IACH,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9F;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWvH;AAED;;;;GAIG;AACH,qBAAa,aAAc,YAAW,iBAAiB;IACrD,OAAO,CAAC,OAAO,CAAW;gBAEd,MAAM,EAAE,QAAQ;IAIrB,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIjE,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIrE,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpE,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAIpG"}
|
|
@@ -1,70 +1,76 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module IModel
|
|
7
|
-
*/
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { getTestOutputDir } from "./Helpers";
|
|
13
|
-
/**
|
|
14
|
-
* Function that creates an iModel and returns a connection to it.
|
|
15
|
-
* @param name Name of test IModel
|
|
16
|
-
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
17
|
-
*
|
|
18
|
-
* @beta
|
|
19
|
-
*/
|
|
20
|
-
export async function buildTestIModel(name, cb) {
|
|
21
|
-
const outputFile = setupOutputFileLocation(name);
|
|
22
|
-
const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
23
|
-
const builder = new IModelBuilder(db);
|
|
24
|
-
try {
|
|
25
|
-
cb(builder);
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
db.saveChanges("Created test IModel");
|
|
29
|
-
db.close();
|
|
30
|
-
}
|
|
31
|
-
return SnapshotConnection.openFile(outputFile);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
export class IModelBuilder {
|
|
39
|
-
constructor(iModel) {
|
|
40
|
-
this
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this._iModel.
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module IModel
|
|
7
|
+
*/
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { IModelJsFs, SnapshotDb } from "@itwin/core-backend";
|
|
10
|
+
import { Code } from "@itwin/core-common";
|
|
11
|
+
import { SnapshotConnection } from "@itwin/core-frontend";
|
|
12
|
+
import { getTestOutputDir } from "./Helpers";
|
|
13
|
+
/**
|
|
14
|
+
* Function that creates an iModel and returns a connection to it.
|
|
15
|
+
* @param name Name of test IModel
|
|
16
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export async function buildTestIModel(name, cb) {
|
|
21
|
+
const outputFile = setupOutputFileLocation(name);
|
|
22
|
+
const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
23
|
+
const builder = new IModelBuilder(db);
|
|
24
|
+
try {
|
|
25
|
+
cb(builder);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
db.saveChanges("Created test IModel");
|
|
29
|
+
db.close();
|
|
30
|
+
}
|
|
31
|
+
return SnapshotConnection.openFile(outputFile);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export class IModelBuilder {
|
|
39
|
+
constructor(iModel) {
|
|
40
|
+
Object.defineProperty(this, "_iModel", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: void 0
|
|
45
|
+
});
|
|
46
|
+
this._iModel = iModel;
|
|
47
|
+
}
|
|
48
|
+
insertModel(props) {
|
|
49
|
+
return this._iModel.models.insertModel(props);
|
|
50
|
+
}
|
|
51
|
+
insertElement(props) {
|
|
52
|
+
return this._iModel.elements.insertElement(props);
|
|
53
|
+
}
|
|
54
|
+
insertAspect(props) {
|
|
55
|
+
this._iModel.elements.insertAspect(props);
|
|
56
|
+
}
|
|
57
|
+
createCode(scopeModelId, codeSpecName, codeValue) {
|
|
58
|
+
const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
|
|
59
|
+
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Prepare for an output file by:
|
|
64
|
+
* - Resolving the output file name under the known test output directory
|
|
65
|
+
* - Making directories as necessary
|
|
66
|
+
* - Removing a previous copy of the output file
|
|
67
|
+
* @param fileName Name of output file
|
|
68
|
+
*/
|
|
69
|
+
function setupOutputFileLocation(fileName) {
|
|
70
|
+
const testOutputDir = getTestOutputDir();
|
|
71
|
+
!IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);
|
|
72
|
+
const outputFile = path.join(testOutputDir, `${fileName}.bim`);
|
|
73
|
+
IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);
|
|
74
|
+
return outputFile;
|
|
75
|
+
}
|
|
70
76
|
//# sourceMappingURL=IModelUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAe,IAAI,EAAyF,MAAM,oBAAoB,CAAC;AAC9I,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAe,IAAI,EAAyF,MAAM,oBAAoB,CAAC;AAC9I,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAqB7C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY,EAAE,EAAwC;IAC1F,MAAM,UAAU,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;IACtC,IAAI;QACF,EAAE,CAAC,OAAO,CAAC,CAAC;KACb;YAAS;QACR,EAAE,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;QACtC,EAAE,CAAC,KAAK,EAAE,CAAC;KACZ;IACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAGxB,YAAY,MAAgB;QAF5B;;;;;WAA0B;QAGxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,WAAW,CAA4B,KAAa;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,aAAa,CAA8B,KAAa;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,YAAY,CAAoC,KAAa;QAClE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEM,UAAU,CAAC,YAA4B,EAAE,YAAyB,EAAE,SAAiB;QAC1F,MAAM,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IAC/D,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModel\n */\n\nimport path from \"path\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementAspectProps, ElementProps, LocalFileName, ModelProps } from \"@itwin/core-common\";\nimport { IModelConnection, SnapshotConnection } from \"@itwin/core-frontend\";\nimport { getTestOutputDir } from \"./Helpers\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): void;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n *\n * @beta\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection> {\n const outputFile = setupOutputFileLocation(name);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new IModelBuilder(db);\n try {\n cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return SnapshotConnection.openFile(outputFile);\n}\n\n/**\n * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @internal\n */\nexport class IModelBuilder implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): void {\n this._iModel.elements.insertAspect(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n */\nfunction setupOutputFileLocation(fileName: string): LocalFileName {\n const testOutputDir = getTestOutputDir();\n !IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);\n\n const outputFile = path.join(testOutputDir, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n"]}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Hierarchies
|
|
3
|
-
*
|
|
4
|
-
* @docs-group-description Hierarchies
|
|
5
|
-
* Types for testing hierarchies.
|
|
6
|
-
*/
|
|
7
|
-
export * from "./presentation-testing/HierarchyBuilder";
|
|
8
|
-
/**
|
|
9
|
-
* @module Content
|
|
10
|
-
*
|
|
11
|
-
* @docs-group-description Content
|
|
12
|
-
* Types for testing content.
|
|
13
|
-
*/
|
|
14
|
-
export * from "./presentation-testing/ContentBuilder";
|
|
15
|
-
/**
|
|
16
|
-
* @module Helpers
|
|
17
|
-
*
|
|
18
|
-
* @docs-group-description Helpers
|
|
19
|
-
* Various test helpers.
|
|
20
|
-
*/
|
|
21
|
-
export * from "./presentation-testing/Helpers";
|
|
22
|
-
/**
|
|
23
|
-
* @module IModel
|
|
24
|
-
*
|
|
25
|
-
* @docs-group-description IModel
|
|
26
|
-
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
27
|
-
*/
|
|
28
|
-
export * from "./presentation-testing/IModelUtilities";
|
|
1
|
+
/**
|
|
2
|
+
* @module Hierarchies
|
|
3
|
+
*
|
|
4
|
+
* @docs-group-description Hierarchies
|
|
5
|
+
* Types for testing hierarchies.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./presentation-testing/HierarchyBuilder";
|
|
8
|
+
/**
|
|
9
|
+
* @module Content
|
|
10
|
+
*
|
|
11
|
+
* @docs-group-description Content
|
|
12
|
+
* Types for testing content.
|
|
13
|
+
*/
|
|
14
|
+
export * from "./presentation-testing/ContentBuilder";
|
|
15
|
+
/**
|
|
16
|
+
* @module Helpers
|
|
17
|
+
*
|
|
18
|
+
* @docs-group-description Helpers
|
|
19
|
+
* Various test helpers.
|
|
20
|
+
*/
|
|
21
|
+
export * from "./presentation-testing/Helpers";
|
|
22
|
+
/**
|
|
23
|
+
* @module IModel
|
|
24
|
+
*
|
|
25
|
+
* @docs-group-description IModel
|
|
26
|
+
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
27
|
+
*/
|
|
28
|
+
export * from "./presentation-testing/IModelUtilities";
|
|
29
29
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/**
|
|
6
|
-
* @module Hierarchies
|
|
7
|
-
*
|
|
8
|
-
* @docs-group-description Hierarchies
|
|
9
|
-
* Types for testing hierarchies.
|
|
10
|
-
*/
|
|
11
|
-
export * from "./presentation-testing/HierarchyBuilder";
|
|
12
|
-
/**
|
|
13
|
-
* @module Content
|
|
14
|
-
*
|
|
15
|
-
* @docs-group-description Content
|
|
16
|
-
* Types for testing content.
|
|
17
|
-
*/
|
|
18
|
-
export * from "./presentation-testing/ContentBuilder";
|
|
19
|
-
/**
|
|
20
|
-
* @module Helpers
|
|
21
|
-
*
|
|
22
|
-
* @docs-group-description Helpers
|
|
23
|
-
* Various test helpers.
|
|
24
|
-
*/
|
|
25
|
-
export * from "./presentation-testing/Helpers";
|
|
26
|
-
/**
|
|
27
|
-
* @module IModel
|
|
28
|
-
*
|
|
29
|
-
* @docs-group-description IModel
|
|
30
|
-
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
31
|
-
*/
|
|
32
|
-
export * from "./presentation-testing/IModelUtilities";
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* @module Hierarchies
|
|
7
|
+
*
|
|
8
|
+
* @docs-group-description Hierarchies
|
|
9
|
+
* Types for testing hierarchies.
|
|
10
|
+
*/
|
|
11
|
+
export * from "./presentation-testing/HierarchyBuilder";
|
|
12
|
+
/**
|
|
13
|
+
* @module Content
|
|
14
|
+
*
|
|
15
|
+
* @docs-group-description Content
|
|
16
|
+
* Types for testing content.
|
|
17
|
+
*/
|
|
18
|
+
export * from "./presentation-testing/ContentBuilder";
|
|
19
|
+
/**
|
|
20
|
+
* @module Helpers
|
|
21
|
+
*
|
|
22
|
+
* @docs-group-description Helpers
|
|
23
|
+
* Various test helpers.
|
|
24
|
+
*/
|
|
25
|
+
export * from "./presentation-testing/Helpers";
|
|
26
|
+
/**
|
|
27
|
+
* @module IModel
|
|
28
|
+
*
|
|
29
|
+
* @docs-group-description IModel
|
|
30
|
+
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
31
|
+
*/
|
|
32
|
+
export * from "./presentation-testing/IModelUtilities";
|
|
33
33
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\nexport * from \"./presentation-testing/Helpers\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "4.0.0-dev.8",
|
|
4
|
+
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/iTwin/
|
|
8
|
+
"url": "https://github.com/iTwin/presentation/tree/master/packages/testing"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"Bentley",
|
|
@@ -19,24 +19,53 @@
|
|
|
19
19
|
},
|
|
20
20
|
"main": "lib/cjs/presentation-testing.js",
|
|
21
21
|
"module": "lib/esm/presentation-testing.js",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
22
|
+
"types": "lib/cjs/presentation-testing.d.ts",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
25
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
26
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
27
|
+
"build:watch": "npm run -s build:cjs -- -w",
|
|
28
|
+
"clean": "rimraf lib",
|
|
29
|
+
"cover": "nyc npm -s test",
|
|
30
|
+
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
31
|
+
"docs:changelog": "cpx ./CHANGELOG.md ../../build/docs/reference/presentation-testing",
|
|
32
|
+
"docs:reference": "betools docs --includes=../../build/docs/extract --json=../../build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
33
|
+
"lint": "eslint ./src/**/*.ts",
|
|
34
|
+
"test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\""
|
|
26
35
|
},
|
|
27
36
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"@itwin/
|
|
32
|
-
"@itwin/
|
|
33
|
-
"@itwin/core-
|
|
34
|
-
"@itwin/core-
|
|
35
|
-
"@itwin/
|
|
36
|
-
"@itwin/
|
|
37
|
-
"@itwin/presentation-
|
|
38
|
-
"@itwin/presentation-
|
|
39
|
-
"@itwin/presentation-frontend": "4.0.0-dev.
|
|
37
|
+
"rimraf": "^3.0.2"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@itwin/appui-abstract": "^3.6.0 || 4.0.0-dev.3",
|
|
41
|
+
"@itwin/components-react": "^3.6.0 || 4.0.0-dev.3",
|
|
42
|
+
"@itwin/core-backend": "^3.6.0 || ^4.0.0-dev.7",
|
|
43
|
+
"@itwin/core-bentley": "^3.6.0 || ^4.0.0-dev.7",
|
|
44
|
+
"@itwin/core-common": "^3.6.0 || ^4.0.0-dev.7",
|
|
45
|
+
"@itwin/core-frontend": "^3.6.0 || ^4.0.0-dev.7",
|
|
46
|
+
"@itwin/presentation-backend": "^3.6.0 || ^4.0.0-dev.7",
|
|
47
|
+
"@itwin/presentation-common": "^3.6.0 || ^4.0.0-dev.7",
|
|
48
|
+
"@itwin/presentation-frontend": "^3.6.0 || ^4.0.0-dev.7",
|
|
49
|
+
"@itwin/presentation-components": "^4.0.0-dev.8"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@itwin/appui-abstract": "4.0.0-dev.3",
|
|
53
|
+
"@itwin/build-tools": "^4.0.0-dev.7",
|
|
54
|
+
"@itwin/components-react": "4.0.0-dev.3",
|
|
55
|
+
"@itwin/core-backend": "^4.0.0-dev.7",
|
|
56
|
+
"@itwin/core-bentley": "^4.0.0-dev.7",
|
|
57
|
+
"@itwin/core-common": "^4.0.0-dev.7",
|
|
58
|
+
"@itwin/core-frontend": "^4.0.0-dev.7",
|
|
59
|
+
"@itwin/core-geometry": "^4.0.0-dev.7",
|
|
60
|
+
"@itwin/core-orbitgt": "^4.0.0-dev.7",
|
|
61
|
+
"@itwin/core-quantity": "^4.0.0-dev.7",
|
|
62
|
+
"@itwin/core-react": "4.0.0-dev.3",
|
|
63
|
+
"@itwin/eslint-plugin": "^4.0.0-dev.7",
|
|
64
|
+
"@itwin/presentation-backend": "^4.0.0-dev.7",
|
|
65
|
+
"@itwin/presentation-common": "^4.0.0-dev.7",
|
|
66
|
+
"@itwin/presentation-frontend": "^4.0.0-dev.7",
|
|
67
|
+
"@itwin/presentation-components": "^4.0.0-dev.8",
|
|
68
|
+
"@itwin/webgl-compatibility": "^4.0.0-dev.7",
|
|
40
69
|
"@types/chai": "4.3.1",
|
|
41
70
|
"@types/chai-as-promised": "^7",
|
|
42
71
|
"@types/chai-jest-snapshot": "^1.3.0",
|
|
@@ -50,6 +79,7 @@
|
|
|
50
79
|
"chai-as-promised": "^7",
|
|
51
80
|
"chai-jest-snapshot": "^2.0.0",
|
|
52
81
|
"cross-env": "^5.1.4",
|
|
82
|
+
"cpx2": "^3.0.0",
|
|
53
83
|
"eslint": "^7.11.0",
|
|
54
84
|
"faker": "^4.1.0",
|
|
55
85
|
"ignore-styles": "^5.0.1",
|
|
@@ -58,41 +88,11 @@
|
|
|
58
88
|
"make-dir": "^1.3.0",
|
|
59
89
|
"mocha": "^10.0.0",
|
|
60
90
|
"nyc": "^15.1.0",
|
|
61
|
-
"
|
|
91
|
+
"react": "^17.0.0",
|
|
92
|
+
"react-dom": "^17.0.0",
|
|
62
93
|
"sinon": "^9.0.2",
|
|
63
94
|
"sinon-chai": "^3.2.0",
|
|
64
95
|
"typemoq": "^2.1.0",
|
|
65
96
|
"typescript": "~4.4.0"
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
"extends": "./node_modules/@itwin/build-tools/.nycrc",
|
|
69
|
-
"check-coverage": true,
|
|
70
|
-
"statements": 100,
|
|
71
|
-
"functions": 100,
|
|
72
|
-
"branches": 100,
|
|
73
|
-
"lines": 100
|
|
74
|
-
},
|
|
75
|
-
"eslintConfig": {
|
|
76
|
-
"plugins": [
|
|
77
|
-
"@itwin"
|
|
78
|
-
],
|
|
79
|
-
"extends": "plugin:@itwin/itwinjs-recommended"
|
|
80
|
-
},
|
|
81
|
-
"scripts": {
|
|
82
|
-
"build": "npm run -s build:cjs",
|
|
83
|
-
"build:ci": "npm run -s build && npm run -s build:esm",
|
|
84
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
85
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
86
|
-
"build:watch": "npm run -s build:cjs -- -w",
|
|
87
|
-
"clean": "rimraf lib .rush/temp/package-deps*.json",
|
|
88
|
-
"cover": "nyc npm -s test",
|
|
89
|
-
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
90
|
-
"docs:changelog": "cpx ./CHANGELOG.md ../../generated-docs/presentation/presentation-testing",
|
|
91
|
-
"docs:reference": "betools docs --json=../../generated-docs/presentation/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**/*",
|
|
92
|
-
"extract": "betools extract --fileExt=ts --extractFrom=./src/test --recursive --out=../../generated-docs/extract",
|
|
93
|
-
"extract-api": "betools extract-api --entry=presentation-testing",
|
|
94
|
-
"lint": "eslint -f visualstudio \"./src/**/*.ts\" 1>&2",
|
|
95
|
-
"test": "mocha -r ignore-styles -r jsdom-global/register --config ../.mocharc.json \"./lib/cjs/test/**/*.test.js\""
|
|
96
|
-
},
|
|
97
|
-
"readme": "# @itwin/presentation-testing\r\n\r\nCopyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.\r\n\r\n## Description\r\n\r\nThe __@itwin/presentation-testing__ package contains helper classes and APIs that help test presentation modules."
|
|
98
|
-
}
|
|
97
|
+
}
|
|
98
|
+
}
|