Merge pull request #6575 from whymarrh/fix-nock-unit-tests

Fix nock usages in unit tests
feature/default_network_editable
Thomas Huang 6 years ago committed by GitHub
commit 50f46386ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      test/unit/ui/app/actions.spec.js
  2. 13
      ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.component.js
  3. 7
      ui/app/pages/send/send-content/send-amount-row/amount-max-button/tests/amount-max-button-component.test.js

@ -1196,7 +1196,6 @@ describe('Actions', () => {
describe('#pairUpdate', () => { describe('#pairUpdate', () => {
beforeEach(() => { beforeEach(() => {
nock('https://shapeshift.io') nock('https://shapeshift.io')
.defaultReplyHeaders({ 'access-control-allow-origin': '*' }) .defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get('/marketinfo/btc_eth') .get('/marketinfo/btc_eth')
@ -1206,10 +1205,6 @@ describe('Actions', () => {
.defaultReplyHeaders({ 'access-control-allow-origin': '*' }) .defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get('/coins') .get('/coins')
.reply(200) .reply(200)
})
afterEach(() => {
nock.restore()
}) })
it('', () => { it('', () => {

@ -15,6 +15,7 @@ export default class AmountMaxButton extends Component {
static contextTypes = { static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
metricsEvent: PropTypes.func,
} }
setMaxAmount () { setMaxAmount () {
@ -35,11 +36,15 @@ export default class AmountMaxButton extends Component {
} }
onMaxClick = (event) => { onMaxClick = (event) => {
const { setMaxModeTo, selectedToken } = this.props const { setMaxModeTo } = this.props
const { metricsEvent } = this.context
fetch('https://chromeextensionmm.innocraft.cloud/piwik.php?idsite=1&rec=1&e_c=send&e_a=amountMax&e_n=' + (selectedToken ? 'token' : 'eth'), { metricsEvent({
'headers': {}, eventOpts: {
'method': 'GET', category: 'Transactions',
action: 'Edit Screen',
name: 'Clicked "Amount Max"',
},
}) })
event.preventDefault() event.preventDefault()

@ -26,7 +26,12 @@ describe('AmountMaxButton Component', function () {
setAmountToMax={propsMethodSpies.setAmountToMax} setAmountToMax={propsMethodSpies.setAmountToMax}
setMaxModeTo={propsMethodSpies.setMaxModeTo} setMaxModeTo={propsMethodSpies.setMaxModeTo}
tokenBalance={'mockTokenBalance'} tokenBalance={'mockTokenBalance'}
/>, { context: { t: str => str + '_t' } }) />, {
context: {
t: str => str + '_t',
metricsEvent: () => {},
},
})
instance = wrapper.instance() instance = wrapper.instance()
}) })

Loading…
Cancel
Save