Skip to content

Commit

Permalink
CXSPA/9197: Remove unused method in major release (#19845)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjana-bl authored Jan 9, 2025
1 parent a3ce331 commit 85e7673
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 65 deletions.
5 changes: 5 additions & 0 deletions docs/migration/2211_ng18/typescript-manual.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changes in feature lib order

## MyAccountV2OrderHistoryService

Method `getOrderDetails` has been removed. Instead directly use `getOrderDetailsV2`.
Original file line number Diff line number Diff line change
Expand Up @@ -179,51 +179,6 @@ describe('MyAccountV2OrderHistoryService', () => {
});
});

describe('getOrderDetails', () => {
it('should load order details when not present in the store', fakeAsync(() => {
spyOn(userService, 'takeUserId').and.callThrough();
const sub = service.getOrderDetails(orderCode).subscribe();

actions$
.pipe(ofType(OrderActions.LOAD_ORDER_BY_ID), take(1))
.subscribe((action) => {
expect(action).toEqual(
new OrderActions.LoadOrderById({
userId: OCC_USER_ID_CURRENT,
code: orderCode,
})
);
});

tick();
expect(userService.takeUserId).toHaveBeenCalled();
expect(store.dispatch).toHaveBeenCalledWith(
new OrderActions.LoadOrderById({
code: orderCode,
userId: OCC_USER_ID_CURRENT,
})
);
sub.unsubscribe();
}));

it('should be able to return order without loading when present in the store', () => {
spyOn(userService, 'takeUserId').and.callThrough();
store.dispatch(new OrderActions.LoadOrderByIdSuccess(order1));
service
.getOrderDetails(orderCode)
.subscribe((data) => {
expect(data).toEqual(order1);
})
.unsubscribe();
expect(userService.takeUserId).not.toHaveBeenCalled();
expect(store.dispatch).not.toHaveBeenCalledWith(
new OrderActions.LoadOrderById({
code: orderCode,
userId: OCC_USER_ID_CURRENT,
})
);
});
});
describe('getOrderDetailsV2', () => {
it('should load order details when not present in the store', fakeAsync(() => {
spyOn(userService, 'takeUserId').and.callThrough();
Expand Down Expand Up @@ -283,6 +238,17 @@ describe('MyAccountV2OrderHistoryService', () => {
})
.unsubscribe();
});
it('should not emit when success and error are null or undefined', () => {
spyOn(service as any, 'getOrderDetailsState').and.returnValue(
of({ success: null, error: undefined, loading: false, value: null })
);
service.getOrderDetailsV2(orderCode).subscribe(() => {
fail('Should not emit any value');
});
expect((service as any).getOrderDetailsState).toHaveBeenCalledWith(
orderCode
);
});
});
describe('getOrderDetailsWithTracking', () => {
it('should return order details with consignment tracking', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,6 @@ export class MyAccountV2OrderHistoryService {
});
}

//TODO: CXINT-2896: Remove this method in next major release
/**
* @deprecated since 2211.20. Use getOrderDetailsV2 instead
*/
getOrderDetails(code: string): Observable<Order> {
const loading$ = this.getOrderDetailsState(code).pipe(
auditTime(0),
tap((state) => {
if (!(state.loading || state.success || state.error)) {
this.loadOrderDetails(code);
}
})
);
return using(
() => loading$.subscribe(),
() => this.getOrderDetailsValue(code)
);
}

//TODO: CXINT-2896: Rename this method to `getOrderDetails` in next major release
getOrderDetailsV2(code: string): Observable<Order | undefined> {
const loading$ = this.getOrderDetailsState(code).pipe(
auditTime(0),
Expand Down

0 comments on commit 85e7673

Please sign in to comment.