-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display current NEO and GAS prices (#331)
* Display current NEO and GAS prices * Better testing * Show NEO/GAS prices review updates * Remove unused import
- Loading branch information
1 parent
c875bd9
commit cc2b1f5
Showing
7 changed files
with
127 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import PriceDisplay from '../../app/components/PriceDisplay' | ||
|
||
describe('PriceDisplay', () => { | ||
test('renders and shows prices', (done) => { | ||
// Full mount (not shallow) so the snapshot will contain the prices in the rendered html. | ||
const wrapper = mount(<PriceDisplay neoPrice={25.48} gasPrice={18.10} />) | ||
expect(wrapper).toMatchSnapshot() | ||
done() | ||
}) | ||
}) |
44 changes: 44 additions & 0 deletions
44
__tests__/components/__snapshots__/PriceDisplay.test.js.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,44 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PriceDisplay renders and shows prices 1`] = ` | ||
<PriceDisplay | ||
gasPrice={18.1} | ||
neoPrice={25.48} | ||
> | ||
<div | ||
className="container" | ||
> | ||
<span | ||
className="neoPriceDisplay" | ||
id="neoPrice" | ||
> | ||
<span | ||
className="label" | ||
> | ||
NEO | ||
</span> | ||
<span | ||
className="price price" | ||
> | ||
$ | ||
25.48 | ||
</span> | ||
</span> | ||
<span | ||
id="gasPrice" | ||
> | ||
<span | ||
className="label" | ||
> | ||
GAS | ||
</span> | ||
<span | ||
className="price price" | ||
> | ||
$ | ||
18.10 | ||
</span> | ||
</span> | ||
</div> | ||
</PriceDisplay> | ||
`; |
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,38 @@ | ||
// @flow | ||
import React from 'react' | ||
import { formatFiat } from '../../core/formatters' | ||
import styles from './PriceDisplay.scss' | ||
import classNames from 'classnames' | ||
|
||
type Props = { | ||
neoPrice: number, | ||
gasPrice: number | ||
} | ||
|
||
const PriceDisplay = ({ neoPrice, gasPrice }: Props) => { | ||
let neoDisplayPrice = '-' | ||
let gasDisplayPrice = '-' | ||
|
||
if (neoPrice) { | ||
neoDisplayPrice = formatFiat(neoPrice) | ||
} | ||
|
||
if (gasPrice) { | ||
gasDisplayPrice = formatFiat(gasPrice) | ||
} | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<span id='neoPrice' className={styles.neoPriceDisplay}> | ||
<span className={styles.label}>NEO</span> | ||
<span className={classNames('price', styles.price)}>${neoDisplayPrice}</span> | ||
</span> | ||
<span id='gasPrice'> | ||
<span className={styles.label}>GAS</span> | ||
<span className={classNames('price', styles.price)}>${gasDisplayPrice}</span> | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
export default PriceDisplay |
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,24 @@ | ||
@import '../../styles/variables'; | ||
|
||
.container { | ||
position: absolute; | ||
font-size: .8em; | ||
opacity: 0.6; | ||
right: 463px; | ||
top: 13px; | ||
} | ||
|
||
.label { | ||
opacity: .6; | ||
margin-right: 4px; | ||
} | ||
|
||
.price { | ||
color: $thin-text-color; | ||
opacity: .8; | ||
cursor: pointer; | ||
} | ||
|
||
.neoPriceDisplay { | ||
padding-right: 38px | ||
} |
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 @@ | ||
export { default } from './PriceDisplay' |
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