title: Unit testing a filter component using Jasmine
body: <p>I have created a component for filtering out a string passed to it. I am trying to write unit test for it and it throwing me an error related to constructor. Please help me.</p>
  
  <pre><code>import angular from 'angular';
  import filter from "./format-string.filter"
  
  angular
  .module( "filters.truncateString", [] )
  .filter( "truncateString", () =&gt; filter );
  
  class TruncateString {
   filter(val){
      const accValue = val.split('YYYY');
      const firstValue= accValue[1].replace(/^(|-?\d+)$/, '');
      return `${accValue[0]} ${firstValue} AAA`;
   }
  }
  
  export default TruncateString .filter;`
  </code></pre>
  
  <p>Test I have written is</p>
  
  <pre><code>import angular from 'angular';
  import 'angular-mocks';
  import TruncateString from './format-string.filter';
  describe('TruncateString filter', () =&gt; {
  let controller, filter;
  
  beforeEach(angular.mock.module('filters.TruncateString'));
  controller = new TruncateString();
  
  beforeEach(inject(function(_$filter_){
      filter = _$filter_;
  }));
  
  it('Checking whether the function is returning formatted string', () =&gt; {
      const result = controller.filter('123YYY3213123');
      expect(result).toHaveBeenCalledWith('123 YYY ... 23');
  });
  });
  </code></pre>