@itwin/presentation-testing 4.0.0-dev.8 → 4.0.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +301 -2
  2. package/LICENSE.md +1 -1
  3. package/README.md +1 -1
  4. package/lib/cjs/presentation-testing/ContentBuilder.d.ts +3 -3
  5. package/lib/cjs/presentation-testing/ContentBuilder.d.ts.map +1 -1
  6. package/lib/cjs/presentation-testing/ContentBuilder.js +27 -27
  7. package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
  8. package/lib/cjs/presentation-testing/Helpers.d.ts +1 -1
  9. package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
  10. package/lib/cjs/presentation-testing/Helpers.js +31 -17
  11. package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
  12. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +2 -2
  13. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
  14. package/lib/cjs/presentation-testing/HierarchyBuilder.js +8 -6
  15. package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
  16. package/lib/cjs/presentation-testing/IModelUtilities.d.ts +19 -5
  17. package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -1
  18. package/lib/cjs/presentation-testing/IModelUtilities.js +16 -13
  19. package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -1
  20. package/lib/cjs/presentation-testing.js +8 -4
  21. package/lib/cjs/presentation-testing.js.map +1 -1
  22. package/lib/esm/presentation-testing/ContentBuilder.d.ts +3 -3
  23. package/lib/esm/presentation-testing/ContentBuilder.d.ts.map +1 -1
  24. package/lib/esm/presentation-testing/ContentBuilder.js +27 -27
  25. package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
  26. package/lib/esm/presentation-testing/Helpers.d.ts +1 -1
  27. package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
  28. package/lib/esm/presentation-testing/Helpers.js +27 -17
  29. package/lib/esm/presentation-testing/Helpers.js.map +1 -1
  30. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +2 -2
  31. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
  32. package/lib/esm/presentation-testing/HierarchyBuilder.js +8 -6
  33. package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
  34. package/lib/esm/presentation-testing/IModelUtilities.d.ts +19 -5
  35. package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -1
  36. package/lib/esm/presentation-testing/IModelUtilities.js +15 -13
  37. package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -1
  38. package/lib/esm/presentation-testing.js +3 -3
  39. package/lib/esm/presentation-testing.js.map +1 -1
  40. package/package.json +36 -32
@@ -1,13 +1,13 @@
1
1
  /** @packageDocumentation
2
2
  * @module IModel
3
3
  */
4
+ /// <reference types="mocha" />
4
5
  import { IModelDb } from "@itwin/core-backend";
5
6
  import { Id64String } from "@itwin/core-bentley";
6
- import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps } from "@itwin/core-common";
7
+ import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
7
8
  import { IModelConnection } from "@itwin/core-frontend";
8
9
  /**
9
10
  * Interface for IModel builder pattern. Used for building IModels to test rulesets.
10
- *
11
11
  * @beta
12
12
  */
13
13
  export interface TestIModelBuilder {
@@ -16,7 +16,12 @@ export interface TestIModelBuilder {
16
16
  /** Insert an element into the builder's iModel */
17
17
  insertElement<TProps extends ElementProps>(props: TProps): Id64String;
18
18
  /** Insert an element aspect into the specified element */
19
- insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
19
+ insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
20
+ /**
21
+ * Insert a relationship between two instances. The relationship is expected to be a subclass
22
+ * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.
23
+ */
24
+ insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
20
25
  /**
21
26
  * Create code for specified element.
22
27
  * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
@@ -27,10 +32,16 @@ export interface TestIModelBuilder {
27
32
  * Function that creates an iModel and returns a connection to it.
28
33
  * @param name Name of test IModel
29
34
  * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
30
- *
31
35
  * @beta
32
36
  */
33
37
  export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
38
+ /**
39
+ * Function that creates an iModel and returns a connection to it.
40
+ * @param mochaContext Mocha context to generate iModel name from
41
+ * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
42
+ * @beta
43
+ */
44
+ export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
34
45
  /**
35
46
  * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
36
47
  *
@@ -41,7 +52,10 @@ export declare class IModelBuilder implements TestIModelBuilder {
41
52
  constructor(iModel: IModelDb);
42
53
  insertModel<TProps extends ModelProps>(props: TProps): Id64String;
43
54
  insertElement<TProps extends ElementProps>(props: TProps): Id64String;
44
- insertAspect<TProps extends ElementAspectProps>(props: TProps): void;
55
+ insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
56
+ insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
45
57
  createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
46
58
  }
59
+ /** @internal */
60
+ export declare function createFileNameFromString(str: string): string;
47
61
  //# 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;AAGH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,C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B,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAexI;;;;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,UAAU;IAI1E,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI/E,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAIpG;AAkBD,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
@@ -1,23 +1,18 @@
1
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
- *--------------------------------------------------------------------------------------------*/
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
5
  /** @packageDocumentation
6
6
  * @module IModel
7
7
  */
8
8
  import path from "path";
9
+ import sanitize from "sanitize-filename";
9
10
  import { IModelJsFs, SnapshotDb } from "@itwin/core-backend";
10
- import { Code } from "@itwin/core-common";
11
+ import { Code, } from "@itwin/core-common";
11
12
  import { SnapshotConnection } from "@itwin/core-frontend";
12
13
  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) {
14
+ export async function buildTestIModel(nameParam, cb) {
15
+ const name = typeof nameParam === "string" ? nameParam : createFileNameFromString(nameParam.test.fullTitle());
21
16
  const outputFile = setupOutputFileLocation(name);
22
17
  const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
23
18
  const builder = new IModelBuilder(db);
@@ -52,7 +47,10 @@ export class IModelBuilder {
52
47
  return this._iModel.elements.insertElement(props);
53
48
  }
54
49
  insertAspect(props) {
55
- this._iModel.elements.insertAspect(props);
50
+ return this._iModel.elements.insertAspect(props);
51
+ }
52
+ insertRelationship(props) {
53
+ return this._iModel.relationships.insertInstance(props);
56
54
  }
57
55
  createCode(scopeModelId, codeSpecName, codeValue) {
58
56
  const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
@@ -73,4 +71,8 @@ function setupOutputFileLocation(fileName) {
73
71
  IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);
74
72
  return outputFile;
75
73
  }
74
+ /** @internal */
75
+ export function createFileNameFromString(str) {
76
+ return sanitize(str.replace(/[ ]+/g, "-")).toLocaleLowerCase();
77
+ }
76
78
  //# 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,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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;;;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
+ {"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA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,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 sanitize from \"sanitize-filename\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec,\n Code,\n CodeScopeProps,\n CodeSpec,\n ElementAspectProps,\n ElementProps,\n LocalFileName,\n ModelProps,\n RelationshipProps,\n} 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 * @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): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\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 * @beta\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\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): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(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\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\")).toLocaleLowerCase();\n}\n"]}
@@ -1,7 +1,7 @@
1
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
- *--------------------------------------------------------------------------------------------*/
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
5
  /**
6
6
  * @module Hierarchies
7
7
  *
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;;;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,12 @@
1
1
  {
2
2
  "name": "@itwin/presentation-testing",
3
- "version": "4.0.0-dev.8",
3
+ "version": "4.0.0",
4
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/presentation/tree/master/packages/testing"
8
+ "url": "https://github.com/iTwin/presentation.git",
9
+ "directory": "packages/testing"
9
10
  },
10
11
  "keywords": [
11
12
  "Bentley",
@@ -34,38 +35,41 @@
34
35
  "test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\""
35
36
  },
36
37
  "dependencies": {
37
- "rimraf": "^3.0.2"
38
+ "rimraf": "^3.0.2",
39
+ "sanitize-filename": "^1.6.3"
38
40
  },
39
41
  "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"
42
+ "@itwin/appui-abstract": "^3.6.3 || ^4.0.0",
43
+ "@itwin/components-react": "^4.0.0",
44
+ "@itwin/core-backend": "^3.6.3 || ^4.0.0",
45
+ "@itwin/core-bentley": "^3.6.3 || ^4.0.0",
46
+ "@itwin/core-common": "^3.6.3 || ^4.0.0",
47
+ "@itwin/core-frontend": "^3.6.3 || ^4.0.0",
48
+ "@itwin/presentation-backend": "^3.6.3 || ^4.0.0",
49
+ "@itwin/presentation-common": "^3.6.3 || ^4.0.0",
50
+ "@itwin/presentation-frontend": "^3.6.3 || ^4.0.0",
51
+ "@itwin/presentation-components": "^4.0.0"
50
52
  },
51
53
  "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",
54
+ "@itwin/appui-abstract": "^4.0.0-dev.90",
55
+ "@itwin/build-tools": "^4.0.0-dev.90",
56
+ "@itwin/components-react": "^4.0.0",
57
+ "@itwin/core-backend": "^4.0.0-dev.90",
58
+ "@itwin/core-bentley": "^4.0.0-dev.90",
59
+ "@itwin/core-common": "^4.0.0-dev.90",
60
+ "@itwin/core-frontend": "^4.0.0-dev.90",
61
+ "@itwin/core-geometry": "^4.0.0-dev.90",
62
+ "@itwin/core-orbitgt": "^4.0.0-dev.90",
63
+ "@itwin/core-quantity": "^4.0.0-dev.90",
64
+ "@itwin/core-react": "^4.0.0",
65
+ "@itwin/ecschema-metadata": "^4.0.0-dev.90",
66
+ "@itwin/eslint-plugin": "^4.0.0-dev.38",
67
+ "@itwin/presentation-backend": "^4.0.0-dev.90",
68
+ "@itwin/presentation-common": "^4.0.0-dev.90",
69
+ "@itwin/presentation-frontend": "^4.0.0-dev.90",
70
+ "@itwin/presentation-components": "^4.0.0",
71
+ "@itwin/webgl-compatibility": "^4.0.0-dev.90",
72
+ "@opentelemetry/api": "^1.4.1",
69
73
  "@types/chai": "4.3.1",
70
74
  "@types/chai-as-promised": "^7",
71
75
  "@types/chai-jest-snapshot": "^1.3.0",
@@ -80,7 +84,7 @@
80
84
  "chai-jest-snapshot": "^2.0.0",
81
85
  "cross-env": "^5.1.4",
82
86
  "cpx2": "^3.0.0",
83
- "eslint": "^7.11.0",
87
+ "eslint": "^8.36.0",
84
88
  "faker": "^4.1.0",
85
89
  "ignore-styles": "^5.0.1",
86
90
  "jsdom": "^19.0.0",
@@ -93,6 +97,6 @@
93
97
  "sinon": "^9.0.2",
94
98
  "sinon-chai": "^3.2.0",
95
99
  "typemoq": "^2.1.0",
96
- "typescript": "~4.4.0"
100
+ "typescript": "~5.0.2"
97
101
  }
98
102
  }