title: How to write a unit test case for a custom validator for angular reactive forms?
body: <p>I have a custom model-driven form validator to validate maximum text length</p>
  
  <pre><code>export function maxTextLength(length: string) {
    return function (control: FormControl) {
      const maxLenghtAllowed: number = +length;
      let value: string = control.value;
      if (value !== '' &amp;&amp; value != null) {
        value = value.trim();
      }
  
      if (value != null &amp;&amp; value.length &gt; maxLenghtAllowed) {
        return { maxTextLength: true };
      }else {
        return null;
      }
    }
  }
  </code></pre>
  
  <p>How to write a unit test case form this?</p>