vendredi 29 janvier 2016

Mocking ag-grid as a dependency using Jasmine

I'm using ag-grid in my application. I need to test a toggle tool panel button function. To do this, though, I need access to ag-grid's api. Here is my unit test I've written so far:

it('toggleToolPanel() should change text on button and change isToolPanelShowing boolean value',function (){
    expect(myScope.toggleToolPanel).toBeDefined();
    //myScope.toggleToolPanel();
    //expect(myScope.buttonText).toBe('Hide Tool Panel');
    //expect(myScope.gridOptions1.api.isToolPanelShowing().toBe(true));
    //expect(myScope.gridOptions4.api.isToolPanelShowing().toBe(true));
    //expect(myScope.gridOptions5.api.isToolPanelShowing().toBe(true));
});

I'm getting isToolPanelShowing() is undefined, which doesn't surprise me. I'm just not sure how to load this dependency (ag-grid) into jasmine so it's api becomes available. Will I need to create mock gridOptions (similar to ui-grid) and a mock column definition within my test file?

Aucun commentaire:

Enregistrer un commentaire