Skip to content

Commit

Permalink
type error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodcog committed Sep 19, 2024
1 parent e0bd9a2 commit 942b430
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions react-components/tests/unit-tests/fixtures/fdmNodeCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { type FdmNodeCache } from '../../../src/components/CacheProvider/FdmNode
import { type FdmNodeCacheContent } from '../../../src/components/CacheProvider/NodeCacheProvider';
import { type DmsUniqueIdentifier } from '../../../src/data-providers/FdmSDK';
import { type TypedReveal3DModel } from '../../../src/components/Reveal3DResources/types';
import { type Node3D } from '@cognite/sdk';
import {
type FdmCadConnection,
type FdmConnectionWithNode
} from '../../../src/components/CacheProvider/types';

const fdmNodeCacheMock = new Mock<FdmNodeCache>()
.setup((instance) => instance.getAllMappingExternalIds)
Expand All @@ -13,32 +18,46 @@ const fdmNodeCacheMock = new Mock<FdmNodeCache>()
) => {
return new Map(
modelRevisionIds.map(({ modelId, revisionId }) => [
`${modelId}-${revisionId}`,
[`externalId-${modelId}/${revisionId}`]
`${modelId}/${revisionId}`,
[
{
connection: {
instance: { space: 'space', externalId: 'id' },
modelId,
revisionId,
treeIndex: 1
} satisfies FdmCadConnection,
cadNode: {
id: 1,
treeIndex: 1,
parentId: 0,
depth: 0,
name: 'node-name',
subtreeSize: 1
} satisfies Node3D
} satisfies FdmConnectionWithNode
]
])
);
}
)
.setup((instance) => instance.getClosestParentDataPromises)
.returns(async (modelId: number, revisionId: number, treeIndex: number) => {
.returns((modelId: number, revisionId: number, treeIndex: number) => {
return {
modelId,
revisionId,
treeIndex,
data: `data-for-${modelId}-${revisionId}-${treeIndex}`
data: `data-for-${modelId}-${revisionId}-${treeIndex}`,
cadAndFdmNodesPromise: Promise.resolve(undefined),
viewsPromise: Promise.resolve([])
};
})
.setup((instance) => instance.getMappingsForFdmInstances)
.returns(async (fdmAssetExternalIds: DmsUniqueIdentifier[], models: TypedReveal3DModel[]) => {
return models.map((model) => ({
modelId: model.modelId,
revisionId: model.revisionId,
mappings: new Map(
fdmAssetExternalIds.map((id) => [
id,
`mapping-for-${JSON.stringify(id)}-${model.modelId}-${model.revisionId}`
])
)
mappings: new Map(fdmAssetExternalIds.map((id) => [JSON.stringify(id), [] as Node3D[]]))
}));
});

Expand Down

0 comments on commit 942b430

Please sign in to comment.