import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { MatDialogModule, MatSnackBarModule } from '@angular/material';
+import { MatDialogModule, MatSnackBarModule, MatDialog } from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormFieldsService } from './form-fields.service';
import 'rxjs/add/observable/of';
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas:[CUSTOM_ELEMENTS_SCHEMA],
+ providers:[MatDialog,DialogOverviewExampleDialog],
declarations: [
FormFieldsComponent,
DialogOverviewExampleDialog
HttpClientTestingModule,
MatDialogModule,
MatSnackBarModule,
- BrowserAnimationsModule
+ BrowserAnimationsModule,
]
})
TestBed.overrideModule(BrowserDynamicTestingModule,{
expect(component).toBeTruthy();
});
+ it('should test moveUpward method',()=>{
+ component.postDownwardObj={"indrijeet":"kumar"};
+ component.reportId1="reportId1";
+ component.formFieldsListObj=[{"id":123},
+ {"id":321}];
+ var responsePostn={"message":true};
+ var postDownwardObj={"orderSeq":1};
+ var finalListResponse={"orderSeq":1};
+ let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj));
+ let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn));
+ let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse));
+ component.moveUpward(1);
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ expect(spy3).toHaveBeenCalled();
+ })
+
+ it('should test moveDownward method',()=>{
+ component.postDownwardObj={"indrijeet":"kumar"};
+ component.reportId1="reportId1";
+ component.formFieldsListObj=[{"id":123},
+ {"id":321}];
+ var responsePostn={"message":true};
+ var postDownwardObj={"orderSeq":1};
+ var finalListResponse={"orderSeq":1};
+ let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj));
+ let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn));
+ let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse));
+ component.moveDownward(0);
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ expect(spy3).toHaveBeenCalled();
+ })
it('should test verify method',()=>{
spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL))
component.openDialog()
})
+ // it('should test openDialog method',()=>{
+ // var result={"Name":"name"};
+ // component.Groups=null;
+ // const dialogRef = component.dialog.open(DialogOverviewExampleDialog, {
+ // width: '400px',
+ // height: '600px',
+ // data: component.formFieldsListObj
+ // });
+ // spyOn(dialogRef,'afterClosed').and.returnValue(result);
+ // component.openDialog();
+ // })
+
it('should test createGroup method',()=>{
let spy=spyOn(component,'openDialog');
component.createGroup();