add bitcoin shop config and payment method enablement
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { validateSync } from 'class-validator';
|
||||
import { IsEnabledPaymentMethods } from './isEnabledPaymentMethods';
|
||||
|
||||
class TestDto {
|
||||
@IsEnabledPaymentMethods()
|
||||
PAYMENT_METHODS_ENABLED: string;
|
||||
}
|
||||
|
||||
const validateMethods = (value: string) => {
|
||||
const dto = Object.assign(new TestDto(), { PAYMENT_METHODS_ENABLED: value });
|
||||
|
||||
return validateSync(dto);
|
||||
};
|
||||
|
||||
describe('IsEnabledPaymentMethods', () => {
|
||||
it('accepts xmr only', () => {
|
||||
expect(validateMethods('xmr')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('accepts xmr and btc', () => {
|
||||
expect(validateMethods('xmr,btc')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('rejects empty string', () => {
|
||||
expect(validateMethods('').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('rejects unsupported methods', () => {
|
||||
expect(validateMethods('eth').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('rejects duplicate methods', () => {
|
||||
expect(validateMethods('xmr,xmr').length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user