forked from aboutmydreams/aiis.read
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from BuidlerDAO/nig-669
feat: 数字展示组件新增快照
- Loading branch information
Showing
12 changed files
with
127 additions
and
52 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,28 @@ | ||
import { render } from '@testing-library/react'; | ||
|
||
import { NumberDisplayer } from './NumberDisplayer'; | ||
|
||
it('balance should display well', () => { | ||
expect(render(<NumberDisplayer text="0.000000180813661601" />).container).toMatchSnapshot(); | ||
}); | ||
it('bignumber should be transform automatically', () => { | ||
expect(render(<NumberDisplayer text="3368437500000000" />).container).toMatchSnapshot(); | ||
}); | ||
it('integer should be append two zero to tail', () => { | ||
expect(render(<NumberDisplayer text="3" />).container).toMatchSnapshot(); | ||
}); | ||
it('if interger part great than 1, decimal part should have 2 decimals', () => { | ||
expect(render(<NumberDisplayer text="3.145" />).container).toMatchSnapshot(); | ||
}); | ||
it('if interger part less than 1, decimal part should have 4 decimals', () => { | ||
expect(render(<NumberDisplayer text="0.145" />).container).toMatchSnapshot(); | ||
}); | ||
it('if interger part great than 1, decimal part should round into 4 decimals', () => { | ||
expect(render(<NumberDisplayer text="0.14235" />).container).toMatchSnapshot(); | ||
}); | ||
|
||
it('should throw error if text is not string', () => { | ||
expect(() => | ||
render(<NumberDisplayer text={3.14 as unknown as string} />) | ||
).toThrowErrorMatchingSnapshot(); | ||
}); |
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
51 changes: 51 additions & 0 deletions
51
src/components/__snapshots__/NumberDisplayer.test.tsx.snap
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,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`balance should display well 1`] = ` | ||
<div> | ||
<span> | ||
0.0{6}1808 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`bignumber should be transform automatically 1`] = ` | ||
<div> | ||
<span> | ||
3368437500000000.00 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`if interger part great than 1, decimal part should have 2 decimals 1`] = ` | ||
<div> | ||
<span> | ||
3.15 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`if interger part great than 1, decimal part should round into 4 decimals 1`] = ` | ||
<div> | ||
<span> | ||
0.1424 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`if interger part less than 1, decimal part should have 4 decimals 1`] = ` | ||
<div> | ||
<span> | ||
0.1450 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`integer should be append two zero to tail 1`] = ` | ||
<div> | ||
<span> | ||
3.00 | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`should throw error if text is not string 1`] = `"text should be string"`; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.