Skip to content

Commit

Permalink
chore: removing unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
anjana-bl committed Aug 22, 2024
1 parent ba5ac89 commit c8b6ed2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,6 @@ describe(`CheckoutServiceDetailsService`, () => {
done();
});
});
it(`should return undefined service detail if no service products are available in cart`, (done) => {
checkoutQuery.getCheckoutDetailsState = createSpy().and.returnValue(
of(<QueryState<CheckoutState>>{
loading: false,
error: false,
data: {
servicedAt: mockData,
},
})
);
spyOn(cartService, 'getEntries').and.returnValue(of([]));

service
.getSelectedServiceDetailsState()
.pipe(take(1))
.subscribe((result) => {
expect(result).toEqual(<QueryState<ServiceDateTime | undefined>>{
loading: false,
error: false,
data: undefined,
});
done();
});
});
});

describe(`setServiceScheduleSlot`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,9 @@ export class CheckoutServiceDetailsService
getSelectedServiceDetailsState(): Observable<
QueryState<ServiceDateTime | undefined>
> {
return this.checkoutQueryFacade.getCheckoutDetailsState().pipe(
switchMap((state) => {
return this.getServiceProducts().pipe(
map((products) => {
if (products.length > 0) {
return { ...state, data: state.data?.servicedAt };
} else {
return { ...state, data: undefined };
}
})
);
})
);
return this.checkoutQueryFacade
.getCheckoutDetailsState()
.pipe(map((state) => ({ ...state, data: state.data?.servicedAt })));
}

getServiceProducts(): Observable<string[]> {
Expand Down

0 comments on commit c8b6ed2

Please sign in to comment.