Need help on testing ejs components

Hi,

Could you please provide some resource on how to test different components like ejs-listbox, ejs-listview, ejs-radiobutton  of EJS2 in Angular 9 app ( e.g testing DataManager).

Thank you!

3 Replies 1 reply marked as answer

GK Gayathri KarunaiAnandam Syncfusion Team February 18, 2021 03:56 PM UTC

Hi Sneha, 

Thank you for contacting Syncfusion support. 

We have checked your reported query. We have prepared a Listbox sample with test cases written in angular platform. We will provide Listbox with datamanager test cases soon. Please refer to the below link: 


Please check the above link and get back to us, if you need further assistance. 

Regards, 
Gayathri K 



SN sneha February 19, 2021 04:39 AM UTC

Hi Gayathri,

I don't have permission to access the sync fusion link which you provided below. 

Thanks,
Sneha


GK Gayathri KarunaiAnandam Syncfusion Team February 20, 2021 11:37 AM UTC

Hi Sneha, 

Sorry for the inconvenience caused. 

We have prepared a Listbox sample using ODataV4Adaptor and written test case for the component as demonstrated in the below code snippet 
 
App.component.spec.ts 
describe('AppComponent', () => { 
  let fixture: ComponentFixture<AppComponent>; 
  var originalTimeout; 
  beforeEach(() => { 
      TestBed.configureTestingModule({ 
      declarations: [ 
        AppComponent 
      ], 
      imports: [ 
        ListBoxAllModule 
      ] 
    }).compileComponents(); 
  }); 
 
  beforeEach(() => { 
    fixture = TestBed.createComponent(AppComponent); 
    fixture.detectChanges(); 
  }); 
 
  it('should create the app', () => { 
    const app = fixture.componentInstance; 
    expect(app).toBeTruthy(); 
  }); 
  it('getDataList method checking', (done: Function) => { 
    const app = fixture.componentInstance; 
    setTimeout(() => { 
      if (app.isDataBound) { 
        expect(app.getDataList()[0].FirstName).toBe('Andrew Fuller'); 
        done(); 
      } 
    }, 1000); 
  }); 
  it('getSortedList method checking', (done: Function) => { 
    const app = fixture.componentInstance; 
    setTimeout(() => { 
      if (app.isDataBound) { 
        expect(app.getSortedList()[0].FirstName).toBe("Steven Buchanan"); 
        done(); 
      } 
    }, 1000); 
  }); 
}); 
 
 
App.component.ts 
export class AppComponent { 
  title = 'angular-unit-testing'; 
   
  @ViewChild('listbox') 
  public listboxObj: ListBoxComponent; 
  public data: DataManager = new DataManager({ 
    url: 'https://ej2services.syncfusion.com/production/web-services/api/Employees', 
    adaptor: new WebApiAdaptor, 
    crossDomain: true 
  }); 
 
  public query: Query = new Query().select(['FirstName''EmployeeID']).take(10).requiresCount(); 
  public field: Object = { text:'FirstName',value: 'FirstName' }; 
  public value: string[] = ["Andrew Fuller"]; 
  public isDataBound: boolean = false; 
   
  dataBound(args) { 
    if (args.name === 'dataBound') { 
      this.isDataBound = true; 
    } 
  } 
 
  getDataList(): { [key: string]: Object; }[] { 
    return this.listboxObj.getDataList() as { [key: string]: Object; }[]; 
  } 
 
  getSortedList(): { [key: string]: Object; }[] { 
    return this.listboxObj.getSortedList() as { [key: string]: Object; }[]; 
  } 
} 
 
 
 
 
 
Please check the above link and get back to us, if you need further assistance. 
 
Regards, 
Gayathri K 


Marked as answer
Loader.
Up arrow icon