• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-web / 12031763437

26 Nov 2024 01:35PM CUT coverage: 79.822%. First build
12031763437

Pull #2982

github

web-flow
Merge d65892e6c into e863f37e0
Pull Request #2982: Confirming that .fill triggers required events in SF

3195 of 4576 branches covered (69.82%)

Branch coverage included in aggregate %.

8977 of 10673 relevant lines covered (84.11%)

710.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/lib/src/components/internal/SecuredFields/binLookup/sortBinLookupBrands.ts
1
import { CVC_POLICY_HIDDEN } from '../lib/constants';
×
2

3
/**
4
 * At some time in the future hopefully the /binLookup will be able to sort the returned brands array according to the criteria below
5
 * But until that happy day we must use the following Utils
6
 */
7
const objByBrand = brandStr => element => element.brand === brandStr;
×
8
const objIsPLCC = element => element.brand.includes('plcc') || element.brand.includes('cbcc');
×
9

10
export const sortBrandsAccordingToRules = (brandsArray: any, cardType: string): any => {
×
11
    // Don't mutate the original
12
    const clonedArr = brandsArray.map(item => ({ ...item }));
×
13

14
    const hasBCMC = clonedArr.some(objByBrand('bcmc'));
×
15
    const hasMaestro = clonedArr.some(objByBrand('maestro'));
×
16
    const hasVisa = clonedArr.some(objByBrand('visa'));
×
17
    const hasCarteBancaire = clonedArr.some(objByBrand('cartebancaire'));
×
18
    const hasPLCC = clonedArr.some(objIsPLCC);
×
19

20
    /**
21
     * RULE 1: if BCMC card component then bcmc is always the first of the dual brands
22
     */
23
    if (cardType === 'bcmc' && hasBCMC) {
×
24
        if (clonedArr[0].brand !== 'bcmc') clonedArr.reverse();
×
25
    }
26

27
    /**
28
     * RULE 2: if BCMC card component & bcmc is dual branded with maestro
29
     *  - maestro has cvcPolicy:'hidden'
30
     *  TODO - NOTE: this now applies to all situations where bcmc is dual branded with maestro
31
     */
32
    if (cardType === 'bcmc' && hasBCMC && hasMaestro) {
×
33
        clonedArr[1].cvcPolicy = CVC_POLICY_HIDDEN; // Maestro already placed into index 1 by Rule 1
×
34
    }
35

36
    /**
37
     * RULE 3: if regular card and dual branding contains Visa & Cartebancaire - ensure Visa is first
38
     */
39
    if (cardType === 'card' && hasVisa && hasCarteBancaire) {
×
40
        if (clonedArr[0].brand !== 'visa') clonedArr.reverse();
×
41
    }
42

43
    /**
44
     * RULE 4: if regular card and dual branding contains a PLCC this should be shown first
45
     */
46
    if (cardType === 'card' && hasPLCC) {
×
47
        if (!clonedArr[0].brand.includes('plcc') && !clonedArr[0].brand.includes('cbcc')) clonedArr.reverse();
×
48
    }
49

50
    return clonedArr;
×
51
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc