Skip to content

Commit

Permalink
fix: bug in bank-account-cards.component.ts (#3336)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumrender authored Dec 12, 2024
1 parent 46a5063 commit aa39031
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
26 changes: 0 additions & 26 deletions src/app/fyle/personal-cards/personal-cards.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,32 +1052,6 @@ describe('PersonalCardsPage', () => {
expect(component.usePlatformApi).toBeTrue();
});

it('should call onCardChanged when linkedAccounts$ emits a non-empty value', (done) => {
const subject = new BehaviorSubject<PersonalCard[]>([]);
component.linkedAccounts$ = subject.asObservable();

component.ngAfterViewInit();
subject.next(linkedAccountsRes);

component.linkedAccounts$.subscribe(() => {
expect(component.onCardChanged).toHaveBeenCalledWith(linkedAccountsRes[0].id);
done();
});
});

it('should not call onCardChanged if linkedAccounts$ emits an empty array', (done) => {
const subject = new BehaviorSubject<PersonalCard[]>([]);
component.linkedAccounts$ = subject.asObservable();

component.ngAfterViewInit();
subject.next([]);

component.linkedAccounts$.subscribe(() => {
expect(component.onCardChanged).not.toHaveBeenCalled();
done();
});
});

it('should generate filter pills based on filters', () => {
personalCardsService.generateFilterPills.and.returnValue(allFilterPills);
component.ngAfterViewInit();
Expand Down
7 changes: 0 additions & 7 deletions src/app/fyle/personal-cards/personal-cards.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,6 @@ export class PersonalCardsPage implements OnInit, AfterViewInit {
this.loadAccountCount();
this.loadLinkedAccounts();

this.linkedAccounts$.pipe(takeUntil(this.onPageExit$)).subscribe((linkedAccounts) => {
if (linkedAccounts.length > 0) {
// Initializing the selectedAccount to First account on page load
this.onCardChanged(linkedAccounts[0].id);
}
});

const paginatedPipe = this.loadPersonalTxns();
this.transactions$ = paginatedPipe.pipe(shareReplay(1));
this.filterPills = this.personalCardsService.generateFilterPills(this.filters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class BankAccountCardsComponent {
}

onCardChange(event: Swiper[]): void {
if (!this.minimal && event.length && event[0].realIndex && this.linkedAccounts[event[0].realIndex]) {
if (!this.minimal && event.length && event[0].realIndex !== undefined && this.linkedAccounts[event[0].realIndex]) {
this.changed.emit(this.linkedAccounts[event[0].realIndex].id);
}
}
Expand Down

0 comments on commit aa39031

Please sign in to comment.