- Home
- Forum
- Angular - EJ 2
- Testing ejGrid editing with Jasmine.
Testing ejGrid editing with Jasmine.
Hi, I am trying to test the ejGrid with Jasmine to test the actionBegin event. I want to select a row, open it in edit mode, find the field and enter a new value into it and save it. And get a triggered event. Something like this:
it("should change data when input value changes", async () => {
component.grid.selectRow(2);
component.grid.startEdit();
let input = debugElement.nativeElement.querySelector("#gridname") as TextBoxComponent;
input.value = "new value";
component.grid.endEdit();
fixture.detectChanges();
expect(component.gridData[2].name).toBe("new value");
});
The problem is that the grid is not initialized during the test. In DOM it looks like this:
<ejs-grid id="grid" ng-reflect-data-source="[object Object],[object Object" ng-reflect-edit-settings="[object Object]" ng-reflect-row-height="40" ng-reflect-toolbar="Add,Edit,Delete,Update,Cancel"></ejs-grid>
The tag is empty. He is filled immediately after the test fails.
How to initialize it before the test?
Thanks
SIGN IN To post a reply.
3 Replies
SK
Sujith Kumar Rajkumar
Syncfusion Team
March 19, 2020 09:22 AM UTC
Hi Turboshurik,
Greetings from Syncfusion support.
You can achieve your requirement by using browser’s wait or sleep method to either wait for a particular condition to be satisfied or set it to sleep for a particular amount of time respectively so that the remaining commands get executed only after the condition is satisfied. This is demonstrated in the below code snippet,
|
var EC = protractor.ExpectedConditions;
// Waits for the element of id ‘e-grid-column1 to be visible on the DOM’
browser.wait(EC.visibilityOf(element(by.xpath(“//div[@e-mappinguid=’e-grid-column1’]”))));
// Sleeps for 100 ms
browser.sleep(100); |
Please check below links for your reference,
Documentation links: https://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.wait
Let us know if you have any concerns.
Regards,
Sujith R
TU
Turboshurik
March 24, 2020 12:10 PM UTC
I found a solution here. The problem was with the beforeEach function.
SK
Sujith Kumar Rajkumar
Syncfusion Team
March 25, 2020 07:42 AM UTC
Hi Turboshurik,
We are glad to hear that your problem has been resolved. Please get back to us if you require any further assistance.
Regards,
Sujith R
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TU Turboshurik
- Mar 18, 2020 03:21 PM UTC
- Mar 25, 2020 07:42 AM UTC