Loëck Vézien
7 years ago
committed by
GitHub
10 changed files with 130 additions and 2 deletions
@ -0,0 +1,6 @@ |
|||
module.exports = { |
|||
globals: { |
|||
__DEV__: true, |
|||
__TEST__: true, |
|||
}, |
|||
} |
@ -0,0 +1,45 @@ |
|||
import React from 'react' |
|||
import { getDefaultUnitByCoinType } from '@ledgerhq/currencies' |
|||
|
|||
import { render } from 'test-utils' |
|||
import FormattedVal from '..' |
|||
|
|||
const bitcoinUnit = getDefaultUnitByCoinType(0) |
|||
|
|||
describe('components', () => { |
|||
describe('FormattedVal', () => { |
|||
it('renders a formatted val', () => { |
|||
const component = <FormattedVal unit={bitcoinUnit} val={400000000} /> |
|||
const tree = render(component) |
|||
expect(tree).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('shows sign', () => { |
|||
const component = <FormattedVal alwaysShowSign unit={bitcoinUnit} val={400000000} /> |
|||
const tree = render(component) |
|||
expect(tree).toMatchSnapshot() |
|||
|
|||
const component2 = <FormattedVal alwaysShowSign unit={bitcoinUnit} val={-400000000} /> |
|||
const tree2 = render(component2) |
|||
expect(tree2).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('shows code', () => { |
|||
const component = <FormattedVal showCode unit={bitcoinUnit} val={400000000} /> |
|||
const tree = render(component) |
|||
expect(tree).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('renders a percent', () => { |
|||
const component = <FormattedVal isPercent val={30} /> |
|||
const tree = render(component) |
|||
expect(tree).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('renders a fiat', () => { |
|||
const component = <FormattedVal fiat="USD" val={20} /> |
|||
const tree = render(component) |
|||
expect(tree).toMatchSnapshot() |
|||
}) |
|||
}) |
|||
}) |
@ -0,0 +1,55 @@ |
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
|||
|
|||
exports[`components FormattedVal renders a fiat 1`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE eCVsWd" |
|||
color="#96d071" |
|||
> |
|||
20.00 |
|||
</span> |
|||
`; |
|||
|
|||
exports[`components FormattedVal renders a formatted val 1`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE eCVsWd" |
|||
color="#96d071" |
|||
> |
|||
4 |
|||
</span> |
|||
`; |
|||
|
|||
exports[`components FormattedVal renders a percent 1`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE eCVsWd" |
|||
color="#96d071" |
|||
> |
|||
30 % |
|||
</span> |
|||
`; |
|||
|
|||
exports[`components FormattedVal shows code 1`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE eCVsWd" |
|||
color="#96d071" |
|||
> |
|||
BTC 4 |
|||
</span> |
|||
`; |
|||
|
|||
exports[`components FormattedVal shows sign 1`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE eCVsWd" |
|||
color="#96d071" |
|||
> |
|||
+ 4 |
|||
</span> |
|||
`; |
|||
|
|||
exports[`components FormattedVal shows sign 2`] = ` |
|||
<span |
|||
className="FormattedVal__T-fevxLy hYRXSf Text-bUpXnE fjJBpt" |
|||
color="#fa4352" |
|||
> |
|||
- 4 |
|||
</span> |
|||
`; |
@ -0,0 +1,9 @@ |
|||
import React from 'react' |
|||
import renderer from 'react-test-renderer' |
|||
import { ThemeProvider } from 'styled-components' |
|||
|
|||
import theme from 'styles/theme' |
|||
|
|||
export function render(component) { |
|||
return renderer.create(<ThemeProvider theme={theme}>{component}</ThemeProvider>).toJSON() |
|||
} |
Loading…
Reference in new issue