generated from valora-inc/typescript-app-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cajubelt/provider-configs
- Loading branch information
Showing
9 changed files
with
223 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { getDropdownValues } from './KYCInfoFieldSection' | ||
import { idTypeReverseFormatter } from './kycInfo/PersonalDataAndDocumentsDetailed' | ||
|
||
describe('KYCInfoFieldSection', () => { | ||
describe('getDropdownValues', () => { | ||
it('returns allowedValues if choices is undefined', () => { | ||
const allowedValues: [string, ...string[]] = ['a', 'b'] | ||
const choices = undefined | ||
const reverseFormatter = undefined | ||
const result = getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}) | ||
expect(result).toEqual(allowedValues) | ||
}) | ||
it('returns choices if allowedValues is undefined', () => { | ||
const allowedValues = undefined | ||
const choices: [string, ...string[]] = ['a', 'b'] | ||
const reverseFormatter = undefined | ||
const result = getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}) | ||
expect(result).toEqual(choices) | ||
}) | ||
it('returns choices that are in allowedValues', () => { | ||
const allowedValues: [string, ...string[]] = ['a', 'b'] | ||
const choices: [string, ...string[]] = ['a', 'b', 'c'] | ||
const reverseFormatter = undefined | ||
const result = getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}) | ||
expect(result).toEqual(allowedValues) | ||
}) | ||
it('returns allowedValues if no choices are in allowedValues', () => { | ||
const allowedValues: [string, ...string[]] = ['a', 'b'] | ||
const choices: [string, ...string[]] = ['c', 'd'] | ||
const reverseFormatter = undefined | ||
const result = getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}) | ||
expect(result).toEqual(allowedValues) | ||
}) | ||
it('returns human-readable values', () => { | ||
const optionAid = 'a' | ||
const optionAhumanReadable = 'Option A' | ||
const optionBid = 'b' | ||
const optionBhumanReadable = 'Option B' | ||
const allowedValues: [string, ...string[]] = [optionAid, optionBid] | ||
const choices: [string, ...string[]] = [ | ||
optionAhumanReadable, | ||
optionBhumanReadable, | ||
'Option C', | ||
] | ||
const reverseFormatter = (optionId: string) => | ||
`Option ${optionId.toUpperCase()}` | ||
expect( | ||
getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}), | ||
).toEqual(['Option A', 'Option B']) | ||
expect( | ||
getDropdownValues({ | ||
allowedValues, | ||
choices: undefined, | ||
reverseFormatter, | ||
}), | ||
).toEqual(['Option A', 'Option B']) | ||
}) | ||
it('works for ID type field', () => { | ||
const allowedValues: [string, ...string[]] = ['IDC', 'PAS'] | ||
const choices: [string, ...string[]] = [ | ||
'State-issued ID', | ||
'Passport', | ||
"Driver's License", | ||
] | ||
const reverseFormatter = idTypeReverseFormatter | ||
const result = getDropdownValues({ | ||
allowedValues, | ||
choices, | ||
reverseFormatter, | ||
}) | ||
expect(result).toEqual(['State-issued ID', 'Passport']) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters