Skip to content

Commit

Permalink
Merge pull request #56 from epilot-dev/feat/normalize-function-suppor…
Browse files Browse the repository at this point in the history
…ts-strings

Feat: Normalize time frequemcy function supports strings
  • Loading branch information
paulofph authored Feb 21, 2024
2 parents 5038118 + 822992d commit 4b87196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/normalizers/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ describe('normalizeTimeFrequency', () => {
${24000} | ${'yearly'} | ${'Monthly'} | ${2000}
${24000} | ${'yearly'} | ${undefined} | ${24000}
${24000} | ${undefined} | ${'monthly'} | ${24000}
${'2400.5'} | ${'monthly'} | ${'weekly'} | ${600.125}
${'1000'} | ${'monthly'} | ${'yearly'} | ${12000}
${'1000.50'}| ${'monthly'} | ${'yearly'} | ${12006}
${'12006'} | ${'yearly'} | ${'monthly'} | ${1000.50}
${'159.345'}| ${'yearly'} | ${'monthly'} | ${13.2788}
`(
`should normalize $timeValue/$timeValueFrequency properly to time frequency $targetTimeFrequency`,
({ timeValue, timeValueFrequency, targetTimeFrequency, expectedNormalizedValue }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export type TimeFrequency = Exclude<BillingPeriod, 'one_time'>;
export type PriceTier = Components.Schemas.PriceTier;
export type PriceTierDisplayMode = Components.Schemas.PriceTierDisplayMode;
export type NormalizeTimeFrequency = (
timeValue: number,
timeValue: number | string,
timeValueFrequency: TimeFrequency,
targetTimeFrequency: TimeFrequency,
precision?: number,
) => number;
export type NormalizeTimeFrequencyToDinero = (
timeValue: number,
timeValue: number | string,
timeValueFrequency: TimeFrequency,
targetTimeFrequency: TimeFrequency,
precision?: number,
Expand Down

0 comments on commit 4b87196

Please sign in to comment.