Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 3x 3x 338x 338x 338x 494x 3380x 2886x 494x 2886x 338x 2886x 338x 338x 3x 3x 3x 3x | import { Type } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import {
CompleteInteractionData,
DepthCameraState,
FrameSizeDefinition,
Interaction,
TrackingConfigState
} from '@reflex/shared-types';
import { NEVER } from 'rxjs';
import type { Mock, MockedObject } from 'vitest';
export function mockService<T>(type: Type<T>): MockedObject<T> {
const methods = new Set<string>();
let prototype: object | null = type.prototype as object;
while (prototype !== null && prototype !== Object.prototype) {
for (const name of Object.getOwnPropertyNames(prototype)) {
if (
name !== 'constructor'
&& typeof Object.getOwnPropertyDescriptor(prototype, name)?.value
=== 'function'
) {
methods.add(name);
}
}
prototype = Object.getPrototypeOf(prototype) as object | null;
}
const mock = Object.fromEntries([...methods].map((name) => [name, vi.fn()])) as MockedObject<T>;
for (const method of methods) {
(mock[method as keyof T] as Mock).mockReturnValue(NEVER);
}
TestBed.overrideProvider(type, { useValue: mock });
return mock;
}
export const streaming: TrackingConfigState = {
isCameraSelected: true,
selectedCameraName: 'Test camera',
selectedConfigurationName: 'Test configuration',
depthCameraStateName: DepthCameraState[DepthCameraState.Streaming]
};
export const frame: FrameSizeDefinition = {
top: 17,
left: 23,
width: 640,
height: 480
};
export const interaction: Interaction = {
touchId: 42,
confidence: 10,
time: 638000000000000000,
type: 0,
extremumDescription: {
type: 0,
numFittingPoints: 10,
percentageFittingPoints: 100
},
position: { x: 0.25, y: 0.5, z: 0.1, isFiltered: false, isValid: true }
};
export const interactionData = (): CompleteInteractionData => ({
raw: [structuredClone(interaction)],
normalized: [structuredClone(interaction)],
absolute: [structuredClone(interaction)]
});
|