Skip to content

Commit

Permalink
test: remaining method in add-edit-exp (#2485)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyashpatil78 authored Oct 5, 2023
1 parent de1a71f commit 15f7e10
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/app/core/mock-data/corporate-card-expense-unflattened.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@ export const eCCCData2: CCCExpUnflattened = {
vendor: null,
},
};

export const eCCCData3: CCCExpUnflattened = {
...expectedECccResponse[0],
balance: {
transfer_settlement_id: 'setxPixUhOPVL',
},
flow: 'newCCCFlow',
ccce: {
...expectedECccResponse[0].ccce,
corporate_credit_card_account_number: '123456789',
},
};
27 changes: 21 additions & 6 deletions src/app/fyle/add-edit-expense/add-edit-expense-6.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ActionSheetController, ModalController, NavController, Platform, PopoverController } from '@ionic/angular';
import { BehaviorSubject, Observable, Subject, Subscription, of } from 'rxjs';
import { AccountType } from 'src/app/core/enums/account-type.enum';
import { eCCCData2, expectedECccResponse } from 'src/app/core/mock-data/corporate-card-expense-unflattened.data';
import {
eCCCData2,
eCCCData3,
expectedECccResponse,
} from 'src/app/core/mock-data/corporate-card-expense-unflattened.data';
import { expectedCCdata, expectedCCdata2 } from 'src/app/core/mock-data/cost-centers.data';
import { defaultTxnFieldValuesData3 } from 'src/app/core/mock-data/default-txn-field-values.data';
import {
Expand Down Expand Up @@ -158,11 +162,11 @@ export function TestCases6(getTestBed) {
popupService = TestBed.inject(PopupService) as jasmine.SpyObj<PopupService>;
navController = TestBed.inject(NavController) as jasmine.SpyObj<NavController>;
corporateCreditCardExpenseService = TestBed.inject(
CorporateCreditCardExpenseService,
CorporateCreditCardExpenseService
) as jasmine.SpyObj<CorporateCreditCardExpenseService>;
trackingService = TestBed.inject(TrackingService) as jasmine.SpyObj<TrackingService>;
recentLocalStorageItemsService = TestBed.inject(
RecentLocalStorageItemsService,
RecentLocalStorageItemsService
) as jasmine.SpyObj<RecentLocalStorageItemsService>;
recentlyUsedItemsService = TestBed.inject(RecentlyUsedItemsService) as jasmine.SpyObj<RecentlyUsedItemsService>;
tokenService = TestBed.inject(TokenService) as jasmine.SpyObj<TokenService>;
Expand Down Expand Up @@ -239,7 +243,7 @@ export function TestCases6(getTestBed) {

expect(platformHandlerService.registerBackButtonAction).toHaveBeenCalledOnceWith(
BackButtonActionPriority.MEDIUM,
jasmine.any(Function),
jasmine.any(Function)
);
expect(dependentFieldSpy.ngOnInit).toHaveBeenCalledTimes(2);
});
Expand All @@ -254,7 +258,7 @@ export function TestCases6(getTestBed) {

expect(platformHandlerService.registerBackButtonAction).toHaveBeenCalledOnceWith(
BackButtonActionPriority.MEDIUM,
jasmine.any(Function),
jasmine.any(Function)
);
});
});
Expand Down Expand Up @@ -347,7 +351,7 @@ export function TestCases6(getTestBed) {
'tax_group_id',
'org_category_id',
],
undefined,
undefined
);
}));

Expand Down Expand Up @@ -512,6 +516,17 @@ export function TestCases6(getTestBed) {
expect(component.fg.controls.bus_travel_class.value).toBeNull();
}));

it('initCCCTxn(): should initialize CCC txn and initialize card number and ending digits', () => {
activatedRoute.snapshot.params = {
bankTxn: JSON.stringify(eCCCData3),
};
component.initCCCTxn();
expect(component.showSelectedTransaction).toBeTrue();
expect(component.selectedCCCTransaction).toEqual(eCCCData3.ccce);
expect(component.isCreatedFromCCC).toBeTrue();
expect(component.cardEndingDigits).toEqual('6789');
});

it('ngOnInit(): should populate report permissions', () => {
activatedRoute.snapshot.params.remove_from_report = JSON.stringify(true);
fixture.detectChanges();
Expand Down

0 comments on commit 15f7e10

Please sign in to comment.