Skip to content

Commit

Permalink
Card brands - Updating property name (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeiroguilherme authored Mar 14, 2022
1 parent d4d479c commit 692da95
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.cardConfig = {
brands: ['visa', 'mc', 'amex', 'discover', 'cup', 'maestro', 'bijcard', 'dineXrs', 'jcb', 'synchrony_cbcc'],
showBrandsInCard: true
showBrandsUnderCardNumber: true
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fixture`Cards - Available brands on Card Component`.page(CARDS_URL).beforeEach(a
cardComponent = new CardComponent('.card-field');
});

test('Available brands show underneath Card Number field if property `showBrandsInCard` is set', async t => {
test('Available brands show underneath Card Number field if property `showBrandsUnderCardNumber` is set', async t => {
const brandsInsidePaymentMethod = Selector('.adyen-checkout__card__brands');
await t.expect(brandsInsidePaymentMethod.find('img').count).eql(10);
}).clientScripts('./availableBrands.clientScripts.js');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
window.mainConfiguration = {
paymentMethodsConfiguration: {
card: {
showBrandsInCard: true
showBrandsUnderCardNumber: true
}
}
};
2 changes: 1 addition & 1 deletion packages/lib/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CardElement extends UIElement<CardElementProps> {

protected static defaultProps = {
onBinLookup: () => {},
showBrandsInCard: false,
showBrandsUnderCardNumber: false,
SRConfig: {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ describe('CardInput', () => {
});

describe('CardInput - Brands beneath Card Number field', () => {
test('should not render brands if property `showBrandsInCard` isnt set', () => {
test('should not render brands if property `showBrandsUnderCardNumber` isnt set', () => {
const wrapper = mount(<CardInput i18n={i18n} />);
expect(wrapper.find('span.adyen-checkout__card__brands').exists()).toBeFalsy();
});

test('should render brands if property `showBrandsInCard` is set', () => {
test('should render brands if property `showBrandsUnderCardNumber` is set', () => {
const brandsIcons = [
{ name: 'visa', icon: 'visa.png' },
{ name: 'mc', icon: 'mc.png' }
];
const wrapper = mount(<CardInput i18n={i18n} showBrandsInCard brandsIcons={brandsIcons} />);
const wrapper = mount(<CardInput i18n={i18n} showBrandsUnderCardNumber brandsIcons={brandsIcons} />);
expect(wrapper.find('.adyen-checkout__card__brands__brand-wrapper')).toHaveLength(2);
expect(wrapper.find('.adyen-checkout__card__brands__brand-wrapper--disabled')).toHaveLength(0);
});
Expand All @@ -75,7 +75,7 @@ describe('CardInput - Brands beneath Card Number field', () => {
{ name: 'mc', icon: 'mc.png' },
{ name: 'amex', icon: 'amex.png' }
];
const wrapper = mount(<CardInput i18n={i18n} brand={detectedBrand} showBrandsInCard brandsIcons={brandsIcons} />);
const wrapper = mount(<CardInput i18n={i18n} brand={detectedBrand} showBrandsUnderCardNumber brandsIcons={brandsIcons} />);
const brands = wrapper.find('.adyen-checkout__card__brands__brand-wrapper');

expect(brands.at(0).is('.adyen-checkout__card__brands__brand-wrapper--disabled')).toBeFalsy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function CardFields({
expiryDatePolicy,
onFocusField,
showBrandIcon,
showBrandsInCard,
showBrandsUnderCardNumber,
valid
}: CardFieldsProps) {
const { i18n } = useCoreContext();
Expand All @@ -50,7 +50,7 @@ export default function CardFields({
dualBrandingSelected={dualBrandingSelected}
/>

{showBrandsInCard && <AvailableBrands activeBrand={brand} brands={brandsIcons} />}
{showBrandsUnderCardNumber && <AvailableBrands activeBrand={brand} brands={brandsIcons} />}

<div
className={classNames('adyen-checkout__card__exp-cvc adyen-checkout__field-wrapper', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const CardFieldsWrapper = ({
positionHolderNameOnTop,
// For CardFields > CardNumber
showBrandIcon,
showBrandsInCard
showBrandsUnderCardNumber
}) => {
const { i18n } = useCoreContext();

Expand Down Expand Up @@ -97,7 +97,7 @@ export const CardFieldsWrapper = ({

<CardFields
showBrandIcon={showBrandIcon}
showBrandsInCard={showBrandsInCard}
showBrandsUnderCardNumber={showBrandsUnderCardNumber}
brand={sfpState.brand}
brandsIcons={brandsIcons}
brandsConfiguration={brandsConfiguration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface CardFieldsProps {
expiryDatePolicy?: DatePolicyType;
onFocusField?: any;
showBrandIcon?: boolean;
showBrandsInCard: boolean;
showBrandsUnderCardNumber: boolean;
valid?: any;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface CardInputProps {
placeholders?: Placeholders;
positionHolderNameOnTop?: boolean;
setComponentRef?: (ref) => void;
showBrandsInCard: boolean;
showBrandsUnderCardNumber: boolean;
showBrandIcon?: boolean;
showInstallmentAmounts?: boolean;
showPayButton?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const extractPropsForCardFields = (props: CardInputProps) => {
positionHolderNameOnTop: props.positionHolderNameOnTop,
// Extract props for CardFields > CardNumber
showBrandIcon: props.showBrandIcon,
showBrandsInCard: props.showBrandsInCard,
showBrandsUnderCardNumber: props.showBrandsUnderCardNumber,
// Extract props for StoredCardFields
lastFour: props.lastFour,
expiryMonth: props.expiryMonth,
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/src/components/Card/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export interface CardElementProps extends UIElementProps {
brands?: string[];

/**
* Show/hide available card brands beneath the Card number field
* Show/hide available card brands under the Card number field
* @defaultValue `false`
*/
showBrandsInCard?: boolean;
showBrandsUnderCardNumber?: boolean;

/**
* Show/hide the brand logo when the card brand has been recognized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class PaymentMethodItem extends Component<PaymentMethodItemProps> {
activeBrand={activeBrand}
brands={paymentMethod.brands}
isPaymentMethodSelected={isSelected}
isCompactView={paymentMethod.props.showBrandsInCard}
isCompactView={paymentMethod.props.showBrandsUnderCardNumber}
/>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/pages/Cards/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ getPaymentMethods({ amount, shopperLocale }).then(async paymentMethodsResponse =
plans: ['regular', 'revolving']
}
},
showBrandsInCard: true,
showBrandsUnderCardNumber: true,
showInstallmentAmounts: true,
onError: obj => {
console.log('### Cards::onError:: obj=', obj);
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/pages/Dropin/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function initSession() {
buttonType: 'plain'
},
card: {
showBrandsInCard: true
showBrandsUnderCardNumber: true
}
}
});
Expand Down

0 comments on commit 692da95

Please sign in to comment.