Skip to content

Instantly share code, notes, and snippets.

@dmitry-stepanenko
Last active September 3, 2022 12:07
Show Gist options
  • Save dmitry-stepanenko/ae67bac6491507f5a1b0a19859f1b54b to your computer and use it in GitHub Desktop.
Save dmitry-stepanenko/ae67bac6491507f5a1b0a19859f1b54b to your computer and use it in GitHub Desktop.
import { runValueAccessorTests } from 'ngx-cva-test-suite';
import { CounterControlComponent } from './counter.component';
runValueAccessorTests({
/** Component, that is being tested */
component: CounterControlComponent,
/**
* All the metadata required for this test to run.
* Under the hood calls TestBed.configureTestingModule with provided config.
*/
testModuleMetadata: {
declarations: [CounterControlComponent],
},
/** Whether component is able to track "onBlur" events separately */
supportsOnBlur: false,
/**
* Tests the correctness of an approach that is used to set value in the component,
* when the change is internal. It's optional and can be omitted by passing "null"
*/
internalValueChangeSetter: null,
/** Function to get the value of a component in a runtime. */
getComponentValue: (fixture) => fixture.componentInstance.value,
/** When component is reset by FormControl, it should either get a certain default internal value or "null" */
resetCustomValue: { value: 0 },
/**
* This test suite applies up to 3 different values on the component to test different use cases.
* Values can be customized using this configuration option.
*/
getValues: () => [1, 2, 3],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment