Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
swap-v2-sdk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
swap-v2-sdk
Commits
cdaa8df1
Unverified
Commit
cdaa8df1
authored
Jun 04, 2019
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix formatting tests
parent
e572535a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
format.ts
src/__tests__/format.ts
+22
-6
No files found.
src/__tests__/format.ts
View file @
cdaa8df1
import
BigInteger
from
'
bignumber.js
'
import
{
FlexibleFormat
,
FormatSignificantOptions
,
FormatFixedOptions
}
from
'
../types
'
import
{
FlexibleFormat
,
FormatSignificantOptions
,
FormatFixedOptions
}
from
'
../types
'
import
{
formatSignificant
,
format
Fixed
}
from
'
../format
'
import
{
formatSignificant
,
format
SignificantDecimals
,
formatFixed
,
formatFixedDecimals
}
from
'
../format
'
import
{
FIXED_UNDERFLOW_BEHAVIOR
}
from
'
../constants
'
import
{
FIXED_UNDERFLOW_BEHAVIOR
,
ROUNDING_MODE
}
from
'
../constants
'
function
constructFormatSignificantOptions
(
function
constructFormatSignificantOptions
(
significantDigits
:
number
,
significantDigits
:
number
,
roundingMode
:
BigInteger
.
RoundingMode
=
ROUNDING_MODE
,
forceIntegerSignificance
:
boolean
=
false
,
forceIntegerSignificance
:
boolean
=
false
,
format
:
FlexibleFormat
=
false
format
:
FlexibleFormat
=
false
):
FormatSignificantOptions
{
):
FormatSignificantOptions
{
return
{
return
{
significantDigits
,
significantDigits
,
roundingMode
,
forceIntegerSignificance
,
forceIntegerSignificance
,
format
format
}
}
...
@@ -16,15 +20,17 @@ function constructFormatSignificantOptions(
...
@@ -16,15 +20,17 @@ function constructFormatSignificantOptions(
function
constructFormatFixedOptions
(
function
constructFormatFixedOptions
(
decimalPlaces
:
number
,
decimalPlaces
:
number
,
roundingMode
:
BigInteger
.
RoundingMode
=
ROUNDING_MODE
,
dropTrailingZeros
:
boolean
=
true
,
dropTrailingZeros
:
boolean
=
true
,
format
:
FlexibleFormat
=
false
,
underflowBehavior
:
FIXED_UNDERFLOW_BEHAVIOR
=
FIXED_UNDERFLOW_BEHAVIOR
.
ONE_DIGIT
,
underflowBehavior
:
FIXED_UNDERFLOW_BEHAVIOR
=
FIXED_UNDERFLOW_BEHAVIOR
.
ONE_DIGIT
format
:
FlexibleFormat
=
false
):
FormatFixedOptions
{
):
FormatFixedOptions
{
return
{
return
{
decimalPlaces
,
decimalPlaces
,
roundingMode
,
dropTrailingZeros
,
dropTrailingZeros
,
format
,
underflowBehavior
,
underflowBehavior
format
}
}
}
}
...
@@ -33,6 +39,11 @@ describe('formatSignificant', (): void => {
...
@@ -33,6 +39,11 @@ describe('formatSignificant', (): void => {
const
formatted
=
formatSignificant
(
'
1.234
'
,
constructFormatSignificantOptions
(
2
))
const
formatted
=
formatSignificant
(
'
1.234
'
,
constructFormatSignificantOptions
(
2
))
expect
(
formatted
).
toBe
(
'
1.2
'
)
expect
(
formatted
).
toBe
(
'
1.2
'
)
})
})
test
(
'
decimal
'
,
():
void
=>
{
const
formatted
=
formatSignificantDecimals
(
'
1234
'
,
3
,
constructFormatSignificantOptions
(
2
))
expect
(
formatted
).
toBe
(
'
1.2
'
)
})
})
})
describe
(
'
formatFixed
'
,
():
void
=>
{
describe
(
'
formatFixed
'
,
():
void
=>
{
...
@@ -40,4 +51,9 @@ describe('formatFixed', (): void => {
...
@@ -40,4 +51,9 @@ describe('formatFixed', (): void => {
const
formatted
=
formatFixed
(
'
1.234
'
,
constructFormatFixedOptions
(
1
))
const
formatted
=
formatFixed
(
'
1.234
'
,
constructFormatFixedOptions
(
1
))
expect
(
formatted
).
toBe
(
'
1.2
'
)
expect
(
formatted
).
toBe
(
'
1.2
'
)
})
})
test
(
'
regular
'
,
():
void
=>
{
const
formatted
=
formatFixedDecimals
(
'
1234
'
,
3
,
constructFormatFixedOptions
(
1
))
expect
(
formatted
).
toBe
(
'
1.2
'
)
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment