test: cover ENABLED_PAYMENT_TYPES fallback paths
Co-authored-by: gopkg-dev <58848833+gopkg-dev@users.noreply.github.com>
This commit is contained in:
@@ -102,4 +102,13 @@ describe('GET /api/user', () => {
|
||||
expect(data.config.enabledPaymentTypes).toEqual(['alipay', 'wxpay', 'stripe']);
|
||||
expect(mockQueryMethodLimits).toHaveBeenCalledWith(['alipay', 'wxpay', 'stripe']);
|
||||
});
|
||||
|
||||
it('falls back to supported payment types when ENABLED_PAYMENT_TYPES is undefined', async () => {
|
||||
const response = await GET(createRequest());
|
||||
const data = await response.json();
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(data.config.enabledPaymentTypes).toEqual(['alipay', 'wxpay', 'stripe']);
|
||||
expect(mockQueryMethodLimits).toHaveBeenCalledWith(['alipay', 'wxpay', 'stripe']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,12 +55,12 @@ export async function GET(request: NextRequest) {
|
||||
const env = getEnv();
|
||||
initPaymentProviders();
|
||||
const supportedTypes = paymentRegistry.getSupportedTypes();
|
||||
const [user, configuredEnabledTypes, balanceDisabledVal] = await Promise.all([
|
||||
const [user, configuredPaymentTypesRaw, balanceDisabledVal] = await Promise.all([
|
||||
getUser(userId),
|
||||
getSystemConfig('ENABLED_PAYMENT_TYPES'),
|
||||
getSystemConfig('BALANCE_PAYMENT_DISABLED'),
|
||||
]);
|
||||
const enabledTypes = resolveEnabledPaymentTypes(supportedTypes, configuredEnabledTypes);
|
||||
const enabledTypes = resolveEnabledPaymentTypes(supportedTypes, configuredPaymentTypesRaw);
|
||||
const methodLimits = await queryMethodLimits(enabledTypes);
|
||||
const balanceDisabled = balanceDisabledVal === 'true';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user