title: Unit test for angular custom validation
body: <p>Please help out with testing custom validator.
  Two weeks trying to resolve this issue nothing happens.</p>
  
  <p>in html </p>
  
  <pre><code>&lt;div&gt;
  &lt;input type="text" class="value-input"  [(ngModel)]="element.value" name = "RegisterValue" #ValueReg = "ngModel"  [viewRegister] = 'viewChoiceDispleyReg' [viewType] = 'displeyView' valueName&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>directive</p>
  
  <pre><code>import { AbstractControl, ValidatorFn, FormControl } from '@angular/forms';
  import { Directive, ElementRef, Input } from '@angular/core';
  import { NG_VALIDATORS, Validator } from '@angular/forms';
  
  @Directive({
      selector: '[valueName]',
      providers: [
          { provide: NG_VALIDATORS, useExisting: valueValidator, multi: true }
        ]
    })
    export class valueValidator implements Validator{
  
    validator: ValidatorFn;
    @Input('viewType') viewType;
    @Input('viewRegister') viewRegister;
  
    constructor(private elementRef: ElementRef) {
      this.validator = this.validateValueFactory();
    }
  
    validate(c: FormControl) {
      return this.validator(c);
    }
  
    // validation function
    validateValueFactory() : ValidatorFn {
      return (c: AbstractControl) =&gt; {
        console.log("validate: " + c.value + ", view type: " + this.viewType);
        let isValid = c.value === '0';
  
        if(isValid) {
            return null;
        } else {
            return {
                valueName: {
                    valid: false
                }
            };
          }
      }
    } 
  }
  </code></pre>
  
  <p>I've studied a lot of material on stackoverflow on other sites. The main problem is that I don't know how to create a component for testing the validator. In this test the component is to add the required validator for the properties(@viewType, @viewRegister).
  How write unit tests for this validator?</p>