aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/app/buy-eth-url.spec.js
blob: 36646fa685c2592e489f86d6564aaa149f515ab8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const assert = require('assert')
const getBuyEthUrl = require('../../../app/scripts/lib/buy-eth-url')

describe('', function () {
  const mainnet = {
    network: '1',
    amount: 5,
    address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
  }
  const ropsten = {
    network: '3',
  }
  const rinkeby = {
    network: '4',
  }
  const kovan = {
    network: '42',
  }

  it('returns coinbase url with amount and address for network 1', function () {
    const coinbaseUrl = getBuyEthUrl(mainnet)
    const coinbase = coinbaseUrl.match(/(https:\/\/buy.coinbase.com)/)
    const amount = coinbaseUrl.match(/(amount)\D\d/)
    const address = coinbaseUrl.match(/(address)(.*)(?=&)/)

    assert.equal(coinbase[0], 'https://buy.coinbase.com')
    assert.equal(amount[0], 'amount=5')
    assert.equal(address[0], 'address=0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc')

  })

  it('returns metamask ropsten faucet for network 3', function () {
    const ropstenUrl = getBuyEthUrl(ropsten)
    assert.equal(ropstenUrl, 'https://faucet.metamask.io/')
  })

  it('returns rinkeby dapp for network 4', function () {
    const rinkebyUrl = getBuyEthUrl(rinkeby)
    assert.equal(rinkebyUrl, 'https://www.rinkeby.io/')
  })

  it('returns kovan github test faucet for network 42', function () {
    const kovanUrl = getBuyEthUrl(kovan)
    assert.equal(kovanUrl, 'https://github.com/kovan-testnet/faucet')
  })

})