All files / tools/ReFlex.TrackingServer/ClientApp/src/app/processing/interactions interactions.component.test-context.ts

100% Statements 38/38
100% Branches 0/0
100% Functions 8/8
100% Lines 33/33

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 70 71 72 73 74 75 76 771x   1x           1x           1x             4x 4x 4x 4x 100x 100x 100x   100x                       100x 100x 100x 100x 100x 100x   100x 100x 100x 100x 100x     100x   100x   100x       4x 4x         2x 4x 4x 4x 4x      
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CompleteInteractionData, Interaction } from '@reflex/shared-types';
import { InteractionsComponent } from './interactions.component';
 
export let component: InteractionsComponent;
 
export let fixture: ComponentFixture<InteractionsComponent>;
 
export const largeData: CompleteInteractionData = {
  raw: [],
  normalized: [],
  absolute: []
};
 
export const smallData = {
  raw: new Array<Interaction>(),
  normalized: new Array<Interaction>(),
  absolute: new Array<Interaction>()
};
 
function resetInteractionData(): void {
  largeData.raw.length = 0;
  largeData.normalized.length = 0;
  largeData.absolute.length = 0;
  for (let i = 0; i < 25; i++) {
    const x = Math.random();
    const y = Math.random();
    const z = Math.random();
 
    const base: Interaction = {
      time: 1234567,
      confidence: i % 10,
      touchId: i,
      type: 1,
      position: { x: x, y: y, z: z, isFiltered: false, isValid: true },
      extremumDescription: {
        numFittingPoints: 10,
        percentageFittingPoints: 100,
        type: 1
      }
    };
    largeData.normalized.push(base);
    const raw = structuredClone(base);
    raw.position.x *= 10;
    raw.position.y *= 15;
    raw.position.z *= 5;
    largeData.raw.push(raw);
 
    const abs = structuredClone(base);
    abs.position.x *= 100;
    abs.position.y *= 150;
    abs.position.z *= 50;
    largeData.absolute.push(abs);
  }
 
  smallData.raw = largeData.raw.filter((elem, idx) => idx > 20);
 
  smallData.normalized = largeData.normalized.filter((elem, idx) => idx > 20);
 
  smallData.absolute = largeData.absolute.filter((elem, idx) => idx > 20);
}
 
export function setupTests(): void {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [InteractionsComponent]
    }).compileComponents();
  });
 
  beforeEach(() => {
    resetInteractionData();
    fixture = TestBed.createComponent(InteractionsComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });
}