Flex grid unit test cases using jasmine

Posted by: zam.abdulvahid on 24 January 2018, 11:56 pm EST

    • Post Options:
    • Link

    Posted 24 January 2018, 11:56 pm EST

    Hi,

    we are writing unit test cases for wijmo using jasmine framework.

    We were able to start with the sample test cases like grid initialization,triggering selection change and item formatter event, going forward we couldn’t solve the below issues

    const countryCellElement: Element | null = gridNativeElement.querySelectorAll(‘.wj-colheaders .wj-cell.wj-header’)[0];

    expect(countryCellElement).not.toBeNull();

    if (countryCellElement) {

    expect(countryCellElement.textContent).toEqual(‘Name’);

    }

    The countryCellElement is returning ''undefined".

    This is not passing the test case as expected.

    2.We need to check if all the header columns are present/defined,could that be achieved anyway?

    3.we want to test the wijmo functions such as getcelldata,setcelldata etc.

    Would be great if you could provide with more sample test cases for wijmo flex grid.

    Let us know if you require additional details

    Thanks in Advance!

  • Posted 28 January 2018, 6:15 pm EST

    Hi Team,

    Can I have any update on this pl.

    Thanks.

  • Posted 28 January 2018, 11:54 pm EST

    Hi,

    Sorry for the delay. We are looking into this. Will get back to you on this tommorrow.

    Thanks,

    Abhishek

  • Posted 31 January 2018, 4:57 pm EST

    Hi Zam,

    We are sorry for delayed response.

    #1

    We are unable to replicate the issue at our end. Below is the code snippet:

     it(`should display the "active" column header`, async(() => {
        const colHeaderCellElement: Element | null = gridNativeElement.querySelectorAll('.wj-colheaders .wj-cell.wj-header')[5];
        expect(colHeaderCellElement).not.toBeNull();
        if (colHeaderCellElement) {
            expect(colHeaderCellElement.textContent).toEqual('active');
        }
      }));
    

    It passes the test successfully.

    #2

    For this you need to handle loadedRows event and check of rows are loaded. If rows are loaded, the columnHeaders will get rendered.

    #3

    Please elaborate this point how you would like to test Wijmo methods…

    ~Manish

  • Posted 1 February 2018, 2:19 am EST

    Thank you Manish for your feedback.

    Regarding #3 - I would like to read a cell data using the wijmo method ‘getcelldata’. Similary would be trying to set a value to a particular cell using the ‘setcelldata’ method.

    #4. In the same way is there a way I can get the old cell value and new cell value for testing?

    ~ Zam

  • Posted 1 February 2018, 8:13 pm EST

    Hi Zam,

    #3:

    You may call getCellData and setCellData using grid:WjFlexGrid variable. For this, you need to pass cell position with data (For setCellData method to set cell data).

    #4

    The old value can be get only in cellEditEnding event using s.activeEditor.value only if standard editor is used.

    ~Manish

Need extra support?

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

Learn More

Forum Channels