-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 'amountDollars' currency formatting and associated functions
- Loading branch information
Showing
12 changed files
with
285 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,51 @@ | ||
import { IntlShape } from 'react-intl'; | ||
import { useStripes } from '@folio/stripes/core'; | ||
import getIntl from '../../../test/util/getIntl'; | ||
import { ComparisonOperator, CriteriaAggregate, CriteriaAggregateType } from '../../../types/CriteriaTypes'; | ||
import { BursarExportFilterAggregate } from '../types'; | ||
import dtoToAggregateCriteria from './dtoToAggregateCriteria'; | ||
|
||
test.each<[BursarExportFilterAggregate | undefined, CriteriaAggregate | undefined]>([ | ||
[undefined, undefined], | ||
[ | ||
{ | ||
type: 'Aggregate', | ||
property: 'NUM_ROWS', | ||
condition: 'LESS_THAN_EQUAL', | ||
amount: 1523, | ||
}, | ||
{ | ||
type: CriteriaAggregateType.NUM_ROWS, | ||
operator: ComparisonOperator.LESS_THAN_EQUAL, | ||
amount: '1523', | ||
}, | ||
], | ||
[ | ||
{ | ||
type: 'Aggregate', | ||
property: 'TOTAL_AMOUNT', | ||
condition: 'GREATER_THAN', | ||
amount: 1523, | ||
}, | ||
{ | ||
type: CriteriaAggregateType.TOTAL_AMOUNT, | ||
operator: ComparisonOperator.GREATER_THAN, | ||
amountCurrency: '15.23', | ||
}, | ||
], | ||
])('dtoToAggregateCriteria(%s) === %s', (input, expected) => expect(dtoToAggregateCriteria(input)).toEqual(expected)); | ||
// United States | ||
let intlEn: IntlShape; | ||
|
||
beforeAll(() => { | ||
intlEn = getIntl('en-US', 'EST'); | ||
}); | ||
|
||
jest.mock('@folio/stripes/core'); | ||
|
||
const mockedUseStripes = useStripes as jest.Mock; | ||
|
||
describe('dtoToAggregateCriteria', () => { | ||
const stripes = mockedUseStripes(); | ||
|
||
test.each<[BursarExportFilterAggregate | undefined, CriteriaAggregate | undefined]>([ | ||
[undefined, undefined], | ||
[ | ||
{ | ||
type: 'Aggregate', | ||
property: 'NUM_ROWS', | ||
condition: 'LESS_THAN_EQUAL', | ||
amount: 1523, | ||
}, | ||
{ | ||
type: CriteriaAggregateType.NUM_ROWS, | ||
operator: ComparisonOperator.LESS_THAN_EQUAL, | ||
amount: '1523', | ||
}, | ||
], | ||
[ | ||
{ | ||
type: 'Aggregate', | ||
property: 'TOTAL_AMOUNT', | ||
condition: 'GREATER_THAN', | ||
amount: 1523, | ||
}, | ||
{ | ||
type: CriteriaAggregateType.TOTAL_AMOUNT, | ||
operator: ComparisonOperator.GREATER_THAN, | ||
amountCurrency: '15.23', | ||
}, | ||
], | ||
])('dtoToAggregateCriteria(%s) === %s', (input, expected) => expect(dtoToAggregateCriteria(input, stripes, intlEn)).toEqual(expected)); | ||
}); |
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
Oops, something went wrong.