Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha committed Jan 6, 2025
1 parent db8c05c commit c40f957
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,41 @@ export function TestCases2(getTestBed) {
});
});

it('onAddCorporateCardClick(): should open card popover', () => {
orgSettingsService.get.and.returnValue(of(orgSettingsPendingRestrictions));
orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData));
const addCardPopoverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onDidDismiss']);
addCardPopoverSpy.present.and.resolveTo();
addCardPopoverSpy.onDidDismiss.and.resolveTo({ success: true });
popoverController.create.and.resolveTo(addCardPopoverSpy);
spyOn(component, 'handleEnrollmentSuccess');

fixture.detectChanges();
component.onAddCorporateCardClick();
expect(popoverController.create).toHaveBeenCalledOnceWith({
component: AddCorporateCardComponent,
cssClass: 'fy-dialog-popover',
componentProps: {
isVisaRTFEnabled: true,
isMastercardRTFEnabled: true,
isYodleeEnabled: true,
},
describe('onAddCorporateCardClick(): ', () => {
it('should open card popover', () => {
orgSettingsService.get.and.returnValue(of(orgSettingsPendingRestrictions));
orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData));
const addCardPopoverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onDidDismiss']);
addCardPopoverSpy.present.and.resolveTo();
addCardPopoverSpy.onDidDismiss.and.resolveTo({ data: { success: true } });
popoverController.create.and.resolveTo(addCardPopoverSpy);
spyOn(component, 'handleEnrollmentSuccess');

fixture.detectChanges();
component.onAddCorporateCardClick();
expect(popoverController.create).toHaveBeenCalledOnceWith({
component: AddCorporateCardComponent,
cssClass: 'fy-dialog-popover',
componentProps: {
isVisaRTFEnabled: true,
isMastercardRTFEnabled: true,
isYodleeEnabled: true,
},
});
});

it('should not open card popover when success is undefined', () => {
orgSettingsService.get.and.returnValue(of(orgSettingsPendingRestrictions));
orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData));
const addCardPopoverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onDidDismiss']);
addCardPopoverSpy.present.and.resolveTo();
addCardPopoverSpy.onDidDismiss.and.resolveTo({ data: null });
popoverController.create.and.resolveTo(addCardPopoverSpy);
const enrollmentSuccessSpy = spyOn(component, 'handleEnrollmentSuccess');

fixture.detectChanges();
component.onAddCorporateCardClick();
expect(enrollmentSuccessSpy).not.toHaveBeenCalled();
});
});

Expand Down

0 comments on commit c40f957

Please sign in to comment.