@itwin/presentation-testing 4.0.0-dev.41 → 4.0.0-dev.43
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.
|
@@ -81,7 +81,7 @@ function setupOutputFileLocation(fileName) {
|
|
|
81
81
|
}
|
|
82
82
|
/** @internal */
|
|
83
83
|
function createFileNameFromString(str) {
|
|
84
|
-
return (0, sanitize_filename_1.default)(str.replace(
|
|
84
|
+
return (0, sanitize_filename_1.default)(str.replace(/[ ]+/g, "-")).toLocaleLowerCase();
|
|
85
85
|
}
|
|
86
86
|
exports.createFileNameFromString = createFileNameFromString;
|
|
87
87
|
//# sourceMappingURL=IModelUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;AAEH,gDAAwB;AACxB,0EAAyC;AACzC,sDAAuE;AAEvE,oDAU4B;AAC5B,wDAA4E;AAC5E,uCAA6C;AAwCtC,KAAK,UAAU,eAAe,CAAC,SAAiC,EAAE,EAAwC;IAC/G,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,SAAS,CAAC,IAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/G,MAAM,UAAU,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,yBAAU,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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I,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,IAAA,2BAAQ,EAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACjE,CAAC;AAFD,4DAEC","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"]}
|
|
@@ -73,6 +73,6 @@ function setupOutputFileLocation(fileName) {
|
|
|
73
73
|
}
|
|
74
74
|
/** @internal */
|
|
75
75
|
export function createFileNameFromString(str) {
|
|
76
|
-
return sanitize(str.replace(
|
|
76
|
+
return sanitize(str.replace(/[ ]+/g, "-")).toLocaleLowerCase();
|
|
77
77
|
}
|
|
78
78
|
//# sourceMappingURL=IModelUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAEL,IAAI,GAQL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAwC7C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiC,EAAE,EAAwC;IAC/G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,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;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACjE,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.43",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,36 +39,36 @@
|
|
|
39
39
|
"sanitize-filename": "^1.6.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@itwin/appui-abstract": "^3.6.3 || ^4.0.0-dev.
|
|
43
|
-
"@itwin/components-react": "^4.0.0-dev.
|
|
44
|
-
"@itwin/core-backend": "^3.6.3 || ^4.0.0-dev.
|
|
45
|
-
"@itwin/core-bentley": "^3.6.3 || ^4.0.0-dev.
|
|
46
|
-
"@itwin/core-common": "^3.6.3 || ^4.0.0-dev.
|
|
47
|
-
"@itwin/core-frontend": "^3.6.3 || ^4.0.0-dev.
|
|
48
|
-
"@itwin/presentation-backend": "^3.6.3 || ^4.0.0-dev.
|
|
49
|
-
"@itwin/presentation-common": "^3.6.3 || ^4.0.0-dev.
|
|
50
|
-
"@itwin/presentation-frontend": "^3.6.3 || ^4.0.0-dev.
|
|
51
|
-
"@itwin/presentation-components": "^4.0.0-dev.
|
|
42
|
+
"@itwin/appui-abstract": "^3.6.3 || ^4.0.0-dev.90",
|
|
43
|
+
"@itwin/components-react": "^4.0.0-dev.20",
|
|
44
|
+
"@itwin/core-backend": "^3.6.3 || ^4.0.0-dev.90",
|
|
45
|
+
"@itwin/core-bentley": "^3.6.3 || ^4.0.0-dev.90",
|
|
46
|
+
"@itwin/core-common": "^3.6.3 || ^4.0.0-dev.90",
|
|
47
|
+
"@itwin/core-frontend": "^3.6.3 || ^4.0.0-dev.90",
|
|
48
|
+
"@itwin/presentation-backend": "^3.6.3 || ^4.0.0-dev.90",
|
|
49
|
+
"@itwin/presentation-common": "^3.6.3 || ^4.0.0-dev.90",
|
|
50
|
+
"@itwin/presentation-frontend": "^3.6.3 || ^4.0.0-dev.90",
|
|
51
|
+
"@itwin/presentation-components": "^4.0.0-dev.43"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@itwin/appui-abstract": "^4.0.0-dev.
|
|
55
|
-
"@itwin/build-tools": "^4.0.0-dev.
|
|
56
|
-
"@itwin/components-react": "^4.0.0-dev.
|
|
57
|
-
"@itwin/core-backend": "^4.0.0-dev.
|
|
58
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
59
|
-
"@itwin/core-common": "^4.0.0-dev.
|
|
60
|
-
"@itwin/core-frontend": "^4.0.0-dev.
|
|
61
|
-
"@itwin/core-geometry": "^4.0.0-dev.
|
|
62
|
-
"@itwin/core-orbitgt": "^4.0.0-dev.
|
|
63
|
-
"@itwin/core-quantity": "^4.0.0-dev.
|
|
64
|
-
"@itwin/core-react": "^4.0.0-dev.
|
|
65
|
-
"@itwin/ecschema-metadata": "^4.0.0-dev.
|
|
66
|
-
"@itwin/eslint-plugin": "^4.0.0-dev.
|
|
67
|
-
"@itwin/presentation-backend": "^4.0.0-dev.
|
|
68
|
-
"@itwin/presentation-common": "^4.0.0-dev.
|
|
69
|
-
"@itwin/presentation-frontend": "^4.0.0-dev.
|
|
70
|
-
"@itwin/presentation-components": "^4.0.0-dev.
|
|
71
|
-
"@itwin/webgl-compatibility": "^4.0.0-dev.
|
|
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-dev.20",
|
|
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-dev.20",
|
|
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-dev.43",
|
|
71
|
+
"@itwin/webgl-compatibility": "^4.0.0-dev.90",
|
|
72
72
|
"@opentelemetry/api": "^1.4.1",
|
|
73
73
|
"@types/chai": "4.3.1",
|
|
74
74
|
"@types/chai-as-promised": "^7",
|