From 68e13f9b2c1e725bcb5a9d8841271b81bcee9cac Mon Sep 17 00:00:00 2001 From: "Maruf Sharifi (via MelvinBot)" Date: Thu, 22 Oct 2026 05:30:35 +0000 Subject: [PATCH 1/2] Show Bank address before Bank city in the non-USD bank account flow Co-authored-by: Maruf Sharifi --- .../BankInfo/subSteps/BankAccountDetails.tsx | 5 +- .../NonUSD/BankInfo/subSteps/Confirmation.tsx | 3 +- .../NonUSD/utils/sortBankInformationFields.ts | 26 +++++++ tests/unit/sortBankInformationFieldsTest.ts | 72 +++++++++++++++++++ 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts create mode 100644 tests/unit/sortBankInformationFieldsTest.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx index 2739ce9bb871..befe2e484da4 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx @@ -16,6 +16,7 @@ import getTextInputAutocorrectProps from '@libs/getTextInputAutocorrectProps'; import type BankInfoSubStepProps from '@pages/ReimbursementAccount/NonUSD/BankInfo/types'; import {getBankInfoStepValues} from '@pages/ReimbursementAccount/NonUSD/utils/getBankInfoStepValues'; import getInputForValueSet from '@pages/ReimbursementAccount/NonUSD/utils/getInputForValueSet'; +import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -39,7 +40,9 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); - const bankAccountDetailsFields = corpayFields?.formFields?.filter((field) => !field.id.includes(CONST.NON_USD_BANK_ACCOUNT.BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX)); + const bankAccountDetailsFields = corpayFields?.formFields + ? sortBankInformationFields(corpayFields.formFields.filter((field) => !field.id.includes(CONST.NON_USD_BANK_ACCOUNT.BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX))) + : undefined; const subStepKeys: Record = {} as Record; for (const field of bankAccountDetailsFields ?? []) { diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx index 9751fac28c5a..a99f150f08f6 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx @@ -10,6 +10,7 @@ import {getLatestErrorMessage} from '@libs/ErrorUtils'; import type BankInfoSubStepProps from '@pages/ReimbursementAccount/NonUSD/BankInfo/types'; import {getBankInfoStepValues} from '@pages/ReimbursementAccount/NonUSD/utils/getBankInfoStepValues'; import getInputKeysForBankInfoStep from '@pages/ReimbursementAccount/NonUSD/utils/getInputKeysForBankInfoStep'; +import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -26,7 +27,7 @@ function Confirmation({onNext, onMove, isEditing, corpayFields}: BankInfoSubStep const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const inputKeys = getInputKeysForBankInfoStep(corpayFields); - const formFields = corpayFields?.formFields; + const formFields = corpayFields?.formFields ? sortBankInformationFields(corpayFields.formFields) : undefined; const values = useMemo(() => getBankInfoStepValues(inputKeys, reimbursementAccountDraft, reimbursementAccount), [inputKeys, reimbursementAccount, reimbursementAccountDraft]); const summaryItems = useMemo( diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts b/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts new file mode 100644 index 000000000000..b8666d8b6d67 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts @@ -0,0 +1,26 @@ +import CONST from '@src/CONST'; +import type {CorpayFormField} from '@src/types/onyx'; + +/** + * Reorders the bank information fields (bank name, address, city, etc.) to match CONST.CORPAY_FIELDS.BANK_INFORMATION_FIELDS, + * so that Bank address comes before Bank city regardless of the order returned by the API. + * The sorted fields are placed back into the slots those fields held, so every other field keeps its original position. + */ +function sortBankInformationFields(fields: CorpayFormField[]): CorpayFormField[] { + const bankInformationFieldsOrder = CONST.CORPAY_FIELDS.BANK_INFORMATION_FIELDS; + const sortedBankInformationFields = fields + .filter((field) => bankInformationFieldsOrder.includes(field.id)) + .sort((a, b) => bankInformationFieldsOrder.indexOf(a.id) - bankInformationFieldsOrder.indexOf(b.id)); + + let bankInformationFieldIndex = 0; + return fields.map((field) => { + if (!bankInformationFieldsOrder.includes(field.id)) { + return field; + } + const sortedField = sortedBankInformationFields.at(bankInformationFieldIndex) ?? field; + bankInformationFieldIndex++; + return sortedField; + }); +} + +export default sortBankInformationFields; diff --git a/tests/unit/sortBankInformationFieldsTest.ts b/tests/unit/sortBankInformationFieldsTest.ts new file mode 100644 index 000000000000..7843a6aad1fe --- /dev/null +++ b/tests/unit/sortBankInformationFieldsTest.ts @@ -0,0 +1,72 @@ +import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; + +import type {CorpayFormField} from '@src/types/onyx'; + +function createField(id: string): CorpayFormField { + return { + id, + label: id, + errorMessage: '', + isRequired: true, + isRequiredInValueSet: false, + regEx: '', + validationRules: [], + }; +} + +function getIDs(fields: CorpayFormField[]): string[] { + return fields.map((field) => field.id); +} + +describe('sortBankInformationFields', () => { + it('puts Bank address before Bank city when the API returns the city first', () => { + // Given the API returns bankCity before bankAddressLine1, as it does for Croatia/EUR + const fields = [createField('bankName'), createField('bankCity'), createField('bankAddressLine1')]; + + // When the fields are sorted + const sortedFields = sortBankInformationFields(fields); + + // Then Bank address comes first, so picking an address can't overwrite a city the user already typed + expect(getIDs(sortedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity']); + }); + + it('keeps the fields that are not bank information fields in their original slots', () => { + // Given bank information fields mixed with account fields like IBAN and SWIFT + const fields = [createField('accountNumber'), createField('bankPostal'), createField('swiftBicCode'), createField('bankCity'), createField('bankAddressLine1'), createField('IBAN')]; + + // When the fields are sorted + const sortedFields = sortBankInformationFields(fields); + + // Then only the bank information fields are reordered, inside the slots they already held + expect(getIDs(sortedFields)).toEqual(['accountNumber', 'bankAddressLine1', 'swiftBicCode', 'bankCity', 'bankPostal', 'IBAN']); + }); + + it('returns the same order when the fields are already sorted', () => { + // Given fields that already follow the expected order + const fields = [createField('bankName'), createField('bankAddressLine1'), createField('bankCity'), createField('accountNumber')]; + + // When the fields are sorted + const sortedFields = sortBankInformationFields(fields); + + // Then nothing moves + expect(getIDs(sortedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity', 'accountNumber']); + }); + + it('does not mutate the original array', () => { + // Given fields in the wrong order + const fields = [createField('bankCity'), createField('bankAddressLine1')]; + + // When the fields are sorted + sortBankInformationFields(fields); + + // Then the input array is left untouched, since it comes straight from Onyx + expect(getIDs(fields)).toEqual(['bankCity', 'bankAddressLine1']); + }); + + it('returns an empty array when there are no fields', () => { + // Given no fields + // When the fields are sorted + // Then an empty array is returned + expect(sortBankInformationFields([])).toEqual([]); + }); +}); From 4220cb837400dfa645c6d70d251b9dfc306c5347 Mon Sep 17 00:00:00 2001 From: "Maruf Sharifi (via MelvinBot)" Date: Sat, 31 Oct 2026 06:37:09 +0000 Subject: [PATCH 2/2] Only swap Bank address and Bank city instead of sorting all bank information fields Co-authored-by: Maruf Sharifi --- .../BankInfo/subSteps/BankAccountDetails.tsx | 4 +- .../NonUSD/BankInfo/subSteps/Confirmation.tsx | 4 +- .../utils/putBankAddressBeforeBankCity.ts | 24 +++++ .../NonUSD/utils/sortBankInformationFields.ts | 26 ----- .../unit/putBankAddressBeforeBankCityTest.ts | 94 +++++++++++++++++++ tests/unit/sortBankInformationFieldsTest.ts | 72 -------------- 6 files changed, 122 insertions(+), 102 deletions(-) create mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity.ts delete mode 100644 src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts create mode 100644 tests/unit/putBankAddressBeforeBankCityTest.ts delete mode 100644 tests/unit/sortBankInformationFieldsTest.ts diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx index befe2e484da4..e1aea853d93d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/BankAccountDetails.tsx @@ -16,7 +16,7 @@ import getTextInputAutocorrectProps from '@libs/getTextInputAutocorrectProps'; import type BankInfoSubStepProps from '@pages/ReimbursementAccount/NonUSD/BankInfo/types'; import {getBankInfoStepValues} from '@pages/ReimbursementAccount/NonUSD/utils/getBankInfoStepValues'; import getInputForValueSet from '@pages/ReimbursementAccount/NonUSD/utils/getInputForValueSet'; -import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; +import putBankAddressBeforeBankCity from '@pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -41,7 +41,7 @@ function BankAccountDetails({onNext, isEditing, corpayFields}: BankInfoSubStepPr const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const bankAccountDetailsFields = corpayFields?.formFields - ? sortBankInformationFields(corpayFields.formFields.filter((field) => !field.id.includes(CONST.NON_USD_BANK_ACCOUNT.BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX))) + ? putBankAddressBeforeBankCity(corpayFields.formFields.filter((field) => !field.id.includes(CONST.NON_USD_BANK_ACCOUNT.BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX))) : undefined; const subStepKeys: Record = {} as Record; diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx index 71273f086f01..c5a4eecab11d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/subSteps/Confirmation.tsx @@ -10,7 +10,7 @@ import {getLatestErrorMessage} from '@libs/ErrorUtils'; import type BankInfoSubStepProps from '@pages/ReimbursementAccount/NonUSD/BankInfo/types'; import {getBankInfoStepValues} from '@pages/ReimbursementAccount/NonUSD/utils/getBankInfoStepValues'; import getInputKeysForBankInfoStep from '@pages/ReimbursementAccount/NonUSD/utils/getInputKeysForBankInfoStep'; -import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; +import putBankAddressBeforeBankCity from '@pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -27,7 +27,7 @@ function Confirmation({onNext, onMove, isEditing, corpayFields}: BankInfoSubStep const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); const inputKeys = getInputKeysForBankInfoStep(corpayFields); - const formFields = corpayFields?.formFields ? sortBankInformationFields(corpayFields.formFields) : undefined; + const formFields = corpayFields?.formFields ? putBankAddressBeforeBankCity(corpayFields.formFields) : undefined; const values = getBankInfoStepValues(inputKeys, reimbursementAccountDraft, reimbursementAccount); const summaryItems = (formFields ?? []).map((field) => { diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity.ts b/src/pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity.ts new file mode 100644 index 000000000000..ae3233330919 --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity.ts @@ -0,0 +1,24 @@ +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; +import type {CorpayFormField} from '@src/types/onyx'; + +/** + * Swaps the Bank address and Bank city fields when the API returns the city first, + * so picking an address can't overwrite a city the user already typed. Every other field keeps its original position. + */ +function putBankAddressBeforeBankCity(fields: CorpayFormField[]): CorpayFormField[] { + const bankCityIndex = fields.findIndex((field) => field.id === INPUT_IDS.ADDITIONAL_DATA.CORPAY.BANK_CITY); + const bankAddressIndex = fields.findIndex((field) => field.id === INPUT_IDS.ADDITIONAL_DATA.CORPAY.BANK_ADDRESS_LINE_1); + const bankCityField = fields.at(bankCityIndex); + const bankAddressField = fields.at(bankAddressIndex); + + if (bankCityIndex === -1 || bankAddressIndex === -1 || bankAddressIndex < bankCityIndex || !bankCityField || !bankAddressField) { + return fields; + } + + const reorderedFields = [...fields]; + reorderedFields[bankCityIndex] = bankAddressField; + reorderedFields[bankAddressIndex] = bankCityField; + return reorderedFields; +} + +export default putBankAddressBeforeBankCity; diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts b/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts deleted file mode 100644 index b8666d8b6d67..000000000000 --- a/src/pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields.ts +++ /dev/null @@ -1,26 +0,0 @@ -import CONST from '@src/CONST'; -import type {CorpayFormField} from '@src/types/onyx'; - -/** - * Reorders the bank information fields (bank name, address, city, etc.) to match CONST.CORPAY_FIELDS.BANK_INFORMATION_FIELDS, - * so that Bank address comes before Bank city regardless of the order returned by the API. - * The sorted fields are placed back into the slots those fields held, so every other field keeps its original position. - */ -function sortBankInformationFields(fields: CorpayFormField[]): CorpayFormField[] { - const bankInformationFieldsOrder = CONST.CORPAY_FIELDS.BANK_INFORMATION_FIELDS; - const sortedBankInformationFields = fields - .filter((field) => bankInformationFieldsOrder.includes(field.id)) - .sort((a, b) => bankInformationFieldsOrder.indexOf(a.id) - bankInformationFieldsOrder.indexOf(b.id)); - - let bankInformationFieldIndex = 0; - return fields.map((field) => { - if (!bankInformationFieldsOrder.includes(field.id)) { - return field; - } - const sortedField = sortedBankInformationFields.at(bankInformationFieldIndex) ?? field; - bankInformationFieldIndex++; - return sortedField; - }); -} - -export default sortBankInformationFields; diff --git a/tests/unit/putBankAddressBeforeBankCityTest.ts b/tests/unit/putBankAddressBeforeBankCityTest.ts new file mode 100644 index 000000000000..2818ff33b32f --- /dev/null +++ b/tests/unit/putBankAddressBeforeBankCityTest.ts @@ -0,0 +1,94 @@ +import putBankAddressBeforeBankCity from '@pages/ReimbursementAccount/NonUSD/utils/putBankAddressBeforeBankCity'; + +import type {CorpayFormField} from '@src/types/onyx'; + +function createField(id: string): CorpayFormField { + return { + id, + label: id, + errorMessage: '', + isRequired: true, + isRequiredInValueSet: false, + regEx: '', + validationRules: [], + }; +} + +function getIDs(fields: CorpayFormField[]): string[] { + return fields.map((field) => field.id); +} + +describe('putBankAddressBeforeBankCity', () => { + it('puts Bank address before Bank city when the API returns the city first', () => { + // Given the API returns bankCity before bankAddressLine1, as it does for Croatia/EUR + const fields = [createField('bankName'), createField('bankCity'), createField('bankAddressLine1')]; + + // When the fields are reordered + const reorderedFields = putBankAddressBeforeBankCity(fields); + + // Then Bank address comes first, so picking an address can't overwrite a city the user already typed + expect(getIDs(reorderedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity']); + }); + + it('only swaps Bank address and Bank city and leaves every other field where it was', () => { + // Given Bank city and Bank address mixed with other fields like IBAN, SWIFT and Bank postal + const fields = [createField('accountNumber'), createField('bankPostal'), createField('swiftBicCode'), createField('bankCity'), createField('bankAddressLine1'), createField('IBAN')]; + + // When the fields are reordered + const reorderedFields = putBankAddressBeforeBankCity(fields); + + // Then only Bank city and Bank address trade places + expect(getIDs(reorderedFields)).toEqual(['accountNumber', 'bankPostal', 'swiftBicCode', 'bankAddressLine1', 'bankCity', 'IBAN']); + }); + + it('swaps Bank address and Bank city when other fields sit between them', () => { + // Given Bank city and Bank address are not next to each other + const fields = [createField('bankCity'), createField('bankPostal'), createField('bankAddressLine1')]; + + // When the fields are reordered + const reorderedFields = putBankAddressBeforeBankCity(fields); + + // Then the two swap slots and the field between them stays put + expect(getIDs(reorderedFields)).toEqual(['bankAddressLine1', 'bankPostal', 'bankCity']); + }); + + it('returns the same order when Bank address already comes before Bank city', () => { + // Given fields that already have Bank address before Bank city + const fields = [createField('bankName'), createField('bankAddressLine1'), createField('bankCity'), createField('accountNumber')]; + + // When the fields are reordered + const reorderedFields = putBankAddressBeforeBankCity(fields); + + // Then nothing moves + expect(getIDs(reorderedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity', 'accountNumber']); + }); + + it('returns the same order when only one of the two fields is present', () => { + // Given fields with Bank city but no Bank address + const fields = [createField('bankName'), createField('bankCity'), createField('bankPostal')]; + + // When the fields are reordered + const reorderedFields = putBankAddressBeforeBankCity(fields); + + // Then nothing moves + expect(getIDs(reorderedFields)).toEqual(['bankName', 'bankCity', 'bankPostal']); + }); + + it('does not mutate the original array', () => { + // Given fields in the wrong order + const fields = [createField('bankCity'), createField('bankAddressLine1')]; + + // When the fields are reordered + putBankAddressBeforeBankCity(fields); + + // Then the input array is left untouched, since it comes straight from Onyx + expect(getIDs(fields)).toEqual(['bankCity', 'bankAddressLine1']); + }); + + it('returns an empty array when there are no fields', () => { + // Given no fields + // When the fields are reordered + // Then an empty array is returned + expect(putBankAddressBeforeBankCity([])).toEqual([]); + }); +}); diff --git a/tests/unit/sortBankInformationFieldsTest.ts b/tests/unit/sortBankInformationFieldsTest.ts deleted file mode 100644 index 7843a6aad1fe..000000000000 --- a/tests/unit/sortBankInformationFieldsTest.ts +++ /dev/null @@ -1,72 +0,0 @@ -import sortBankInformationFields from '@pages/ReimbursementAccount/NonUSD/utils/sortBankInformationFields'; - -import type {CorpayFormField} from '@src/types/onyx'; - -function createField(id: string): CorpayFormField { - return { - id, - label: id, - errorMessage: '', - isRequired: true, - isRequiredInValueSet: false, - regEx: '', - validationRules: [], - }; -} - -function getIDs(fields: CorpayFormField[]): string[] { - return fields.map((field) => field.id); -} - -describe('sortBankInformationFields', () => { - it('puts Bank address before Bank city when the API returns the city first', () => { - // Given the API returns bankCity before bankAddressLine1, as it does for Croatia/EUR - const fields = [createField('bankName'), createField('bankCity'), createField('bankAddressLine1')]; - - // When the fields are sorted - const sortedFields = sortBankInformationFields(fields); - - // Then Bank address comes first, so picking an address can't overwrite a city the user already typed - expect(getIDs(sortedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity']); - }); - - it('keeps the fields that are not bank information fields in their original slots', () => { - // Given bank information fields mixed with account fields like IBAN and SWIFT - const fields = [createField('accountNumber'), createField('bankPostal'), createField('swiftBicCode'), createField('bankCity'), createField('bankAddressLine1'), createField('IBAN')]; - - // When the fields are sorted - const sortedFields = sortBankInformationFields(fields); - - // Then only the bank information fields are reordered, inside the slots they already held - expect(getIDs(sortedFields)).toEqual(['accountNumber', 'bankAddressLine1', 'swiftBicCode', 'bankCity', 'bankPostal', 'IBAN']); - }); - - it('returns the same order when the fields are already sorted', () => { - // Given fields that already follow the expected order - const fields = [createField('bankName'), createField('bankAddressLine1'), createField('bankCity'), createField('accountNumber')]; - - // When the fields are sorted - const sortedFields = sortBankInformationFields(fields); - - // Then nothing moves - expect(getIDs(sortedFields)).toEqual(['bankName', 'bankAddressLine1', 'bankCity', 'accountNumber']); - }); - - it('does not mutate the original array', () => { - // Given fields in the wrong order - const fields = [createField('bankCity'), createField('bankAddressLine1')]; - - // When the fields are sorted - sortBankInformationFields(fields); - - // Then the input array is left untouched, since it comes straight from Onyx - expect(getIDs(fields)).toEqual(['bankCity', 'bankAddressLine1']); - }); - - it('returns an empty array when there are no fields', () => { - // Given no fields - // When the fields are sorted - // Then an empty array is returned - expect(sortBankInformationFields([])).toEqual([]); - }); -});