import { assert } from "chai" ; import { BisCodeSpec , CodeScopeSpec , CodeSpec } from "@itwin/core-common" ; import { IModelConnection , SnapshotConnection } from "@itwin/core-frontend" ; import { TestUtility } from "../TestUtility" ; describe ( "CodeSpecs" , async ( ) => { let iModel ; before ( async ( ) => { await TestUtility . startFrontend ( ) ; iModel = await SnapshotConnection . openFile ( "test.bim" ) ; } ) ; after ( async ( ) => { if ( iModel ) await iModel . close ( ) ; await TestUtility . shutdownFrontend ( ) ; } ) ; it ( "should load CodeSpecs" , async ( ) => { const nullCodeSpec = await iModel . codeSpecs . getByName ( BisCodeSpec . nullCodeSpec ) ; assert . equal ( nullCodeSpec . scopeType , CodeScopeSpec . Type . Repository ) ; assert . equal ( nullCodeSpec . scopeReq , CodeScopeSpec . ScopeRequirement . ElementId ) ; assert . isTrue ( nullCodeSpec . isManagedWithIModel ) ; const subCategoryCodeSpec = await iModel . codeSpecs . getByName ( BisCodeSpec . subCategory ) ; assert . equal ( subCategoryCodeSpec . scopeType , CodeScopeSpec . Type . ParentElement ) ; assert . equal ( subCategoryCodeSpec . scopeReq , CodeScopeSpec . ScopeRequirement . ElementId ) ; assert . isTrue ( subCategoryCodeSpec . isManagedWithIModel ) ; const viewDefinitionCodeSpec = await iModel . codeSpecs . getByName ( BisCodeSpec . viewDefinition ) ; assert . equal ( viewDefinitionCodeSpec . scopeType , CodeScopeSpec . Type . Model ) ; assert . equal ( viewDefinitionCodeSpec . scopeReq , CodeScopeSpec . ScopeRequirement . ElementId ) ; assert . isTrue ( viewDefinitionCodeSpec . isManagedWithIModel ) ; } ) ; } ) ;