Skip to content

Instantly share code, notes, and snippets.

@topnotch48
Created October 24, 2018 12:40
Show Gist options
  • Save topnotch48/e24ae0c3468cb7d5b2bf157ae6810eb3 to your computer and use it in GitHub Desktop.
Save topnotch48/e24ae0c3468cb7d5b2bf157ae6810eb3 to your computer and use it in GitHub Desktop.
init
function initComponent<TValue, TComponent extends FieldEditorComponent<TValue>>(c: { new (...args: any[]): TComponent },
wellKnownField: WellKnownField,
criteriaValue: any,
valueChangeHandler: (e: FieldEditorValueChangeEvent<TValue>) => void
): TestCtx<TComponent> {
let testCtx = createTestContext(c);
tick();
let field = (<MatterContext>TestBed.get(MatterContext)).matterDefinition!.fieldsDefinition.getWellKnownField(wellKnownField);
let fc = FieldCriteriaFactory.buildCriteria(field, SearchFieldOperator.EQ, criteriaValue);
(<any>testCtx.component).value = fc.value;
(<any>testCtx.component).valueChange.subscribe(valueChangeHandler);
testCtx.fixture.detectChanges();
return testCtx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment