94 lines
3.5 KiB
TypeScript
94 lines
3.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
/**
|
|
* Default outcome per backend procedure.
|
|
*
|
|
* Tests override individual entries with `setProcedure(path, { ... })`. Anything
|
|
* not listed here resolves with `undefined` (the mocked hook then reports the
|
|
* "success + no data" state).
|
|
*/
|
|
import {
|
|
A1,
|
|
ADDRESSES_RESPONSE,
|
|
AUTH_USER,
|
|
CART_SLOTS_RESPONSE,
|
|
C4,
|
|
COMPLAINTS_RESPONSE,
|
|
CONSTS,
|
|
ELIGIBLE_COUPONS_RESPONSE,
|
|
MY_COUPONS_RESPONSE,
|
|
O1,
|
|
ORDERS_RESPONSE,
|
|
PRODUCT_DETAILS,
|
|
REGIONS,
|
|
REGION_1,
|
|
BOUND_1,
|
|
REVIEWS_RESPONSE,
|
|
SELF_DATA_RESPONSE,
|
|
SLOTS,
|
|
} from '../fixtures'
|
|
|
|
export interface ProcConfig {
|
|
mode?: 'success' | 'error' | 'pending'
|
|
data?: any
|
|
error?: unknown
|
|
impl?: (input: any) => any
|
|
}
|
|
|
|
export const defaultProcedures: Record<string, ProcConfig> = {
|
|
// ---- common ----
|
|
'common.healthCheck': { data: { ok: true, status: 'healthy' } },
|
|
'common.listRegions': { data: REGIONS },
|
|
'common.resolveRegionByLocation': { data: { region: REGION_1, bound: BOUND_1 } },
|
|
'common.resolveBound': { data: { regionId: 1, boundId: 7 } },
|
|
'common.activeBound': { data: { regionId: 1, boundId: 7 } },
|
|
'common.regionSettings': { data: {} },
|
|
'common.essentialConsts': { data: CONSTS },
|
|
'common.generateUploadUrls': { data: { uploadUrls: ['https://upload.test/img-1.jpg'] } },
|
|
|
|
// ---- auth ----
|
|
'user.auth.sendOtp': { data: { success: true, message: 'OTP sent successfully' } },
|
|
'user.auth.verifyOtp': { data: { success: true, token: 'test-token', user: AUTH_USER } },
|
|
'user.auth.login': { data: { data: { token: 'test-token', user: AUTH_USER } } },
|
|
'user.auth.register': { data: { data: { token: 'test-token', user: AUTH_USER } } },
|
|
'user.auth.updateProfile': { data: { data: { token: 'test-token', user: AUTH_USER } } },
|
|
'user.auth.updatePassword': { data: { success: true } },
|
|
'user.auth.deleteAccount': { data: { success: true } },
|
|
|
|
// ---- user ----
|
|
'user.user.getSelfData': { data: SELF_DATA_RESPONSE },
|
|
'user.user.savePushToken': { data: { success: true } },
|
|
'user.user.recordTrackedRegion': { data: { success: true } },
|
|
|
|
// ---- address ----
|
|
'user.address.getUserAddresses': { data: ADDRESSES_RESPONSE },
|
|
'user.address.getDefaultAddress': { data: { data: A1 } },
|
|
'user.address.createAddress': { data: { data: A1 } },
|
|
'user.address.updateAddress': { data: { data: A1 } },
|
|
'user.address.deleteAddress': { data: { success: true } },
|
|
|
|
// ---- catalogue ----
|
|
'user.product.getProductDetails': { data: PRODUCT_DETAILS },
|
|
'user.product.getProductReviews': { data: REVIEWS_RESPONSE },
|
|
'user.product.createReview': { data: { success: true } },
|
|
'user.slots.getSlots': { data: { slots: SLOTS, count: SLOTS.length } },
|
|
'user.cart.getCartSlots': { data: CART_SLOTS_RESPONSE },
|
|
|
|
// ---- coupons ----
|
|
'user.coupon.getEligible': { data: ELIGIBLE_COUPONS_RESPONSE },
|
|
'user.coupon.getMyCoupons': { data: MY_COUPONS_RESPONSE },
|
|
'user.coupon.redeemReservedCoupon': { data: { success: true, data: C4 } },
|
|
|
|
// ---- complaints ----
|
|
'user.complaint.getAll': { data: COMPLAINTS_RESPONSE },
|
|
'user.complaint.raise': { data: { success: true } },
|
|
|
|
// ---- orders ----
|
|
'user.order.getOrders': { data: ORDERS_RESPONSE },
|
|
'user.order.getOrderById': { data: O1 },
|
|
'user.order.placeOrder': { data: { data: { orders: [O1] } } },
|
|
'user.order.cancelOrder': { data: { success: true } },
|
|
'user.order.updateUserNotes': { data: { success: true } },
|
|
|
|
// ---- uploads ----
|
|
'user.fileUpload.generateUploadUrls': { data: { uploadUrls: ['https://upload.test/img-1.jpg'] } },
|
|
}
|