Flexgrid Filter Unit Test

Posted by: jaganlal.thoppe on 29 October 2018, 5:49 pm EST

    • Post Options:
    • Link

    Posted 29 October 2018, 5:49 pm EST

    Hi,

    Framework: AngularJS

    I’m using global chaining filter for one of my project, i received the following fiddle from one of the Wijmo Developer (Sharad).

    AngularJs: http://jsfiddle.net/gj603fme/

    This fiddle works like charm, but when i wanted to unit test that global filtering logic, i noticed,

    
    initialized="initFilter(s)"
    
    

    is not getting called from my unit test. Or in other words, when i run the unit test, i don’t see

    initFilter
    function being called.

    The same
    initFilter
    is getting called when it’s in the browser.

    I debugged the code on browser and noted
    initialized
    call back comes from
    setTimeout
    , i tried
    $timeout.flush();
    still not getting called.

    Need some help me on this.

  • Posted 30 October 2018, 3:25 am EST

    Hi Jagan,

    Please handle initialized event for FlexGrid and see if it works or not so that we may confirm if the unit test is working fine or not.

    Also, please provide the modified sample with the Unit test so that we may investigate and assist you ahead.

    ~Manish

  • Posted 30 October 2018, 10:46 am EST

    Hi Manish,

    Thanks for the response.

    I haven’t modified the fiddle (sample) with the Unit Test, i have used the logic from the fiddle and using it inside our application.

    Also, is part of the another custom directive which our devs would use. You can imagine the scenario like this

    
      <my-custom-directive>
        -----
      </my-custom-directive>
    
    

    This boils down to

    
      <div>
         ---
         <input type="text"
                     ng-change="onFilterInput()"
                     ng-model="searchBoxFilter"
                     placeholder="Search">
         <wj-flex-grid initialized="initGrid(s,e)">
           <wj-flex-grid-filter initialized="initFilter(s)" filter-applied="filterApplied(sa)"></wj-flex-grid-filter>
             ---
         </wj-flex-grid>
      </div>
    
    

    I’m testing

    
    1.  var customDirective = createMyCustomDirective();
    2.  angular.element(document.body).append(customDirective);
    3.  scope.$digest();
    4.  $timeout.flush();
    
    5.  // Expecting `initialized="initFilter(s)"` to have been called around this time....
    
    6.  var searchBoxEl = customDirective.find('.custom-search > input');
    7.  angular.element(searchBoxEl).val('99999').trigger('input');
    8.  scope.$apply();
    
    

    Expecting

    initialized="initFilter(s)"
    to have been called after line 4 or sometimes around this time.

    I’m listening for the

    initialized
    event on the flex grid.

    Can you please shed more lights on this?

    Thanks,

    Jagan

  • Posted 30 October 2018, 10:46 am EST

    Hi Manish,

    It got fixed, my bad, i had to include wijmo/controls/wijmo.grid.filter.min.js to karma.js.

    Thanks,

    Jagan

  • Posted 30 October 2018, 11:39 pm EST

    Thanks Jagan for notifying!!!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels