{"size": 2379, "ext": "js", "max_stars_repo_path": "__e2e__/create-new-wallet.e2e.js", "max_stars_repo_name": "snowypowers/neon-wallet", "max_stars_repo_stars_event_min_datetime": "2019-05-21T00:01:38.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-21T01:09:11.000Z", "max_issues_repo_path": "__e2e__/create-new-wallet.e2e.js", "max_issues_repo_name": "digilifecz123/neon-wallet", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "__e2e__/create-new-wallet.e2e.js", "max_forks_repo_name": "digilifecz123/neon-wallet", "max_forks_repo_forks_event_min_datetime": "2018-06-23T13:35:09.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-23T13:35:09.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 33.9857142857, "max_line_length": 98, "alphanum_fraction": 0.7074401009}
import { Application } from 'spectron'
import path from 'path'
import test from 'ava'

let electronPath = path.join(__dirname, '..', 'node_modules', '.bin', 'electron')
if (process.platform === 'win32') {
  electronPath += '.cmd'
}
const appPath = path.join(__dirname, '..')

const app = new Application({
  path: electronPath,
  args: [appPath]
})

test.before(async () => {
  await app.start()
  await app.client.waitUntilWindowLoaded()
})

test.after(async () => {
  if (app && app.isRunning()) {
    await app.stop()
  }
})

function timeout (ms) {
  return new Promise(resolve => setTimeout(resolve, ms))
}

test.serial('should create new wallet', async t => {
  // Go to create wallet page
  await app.client.waitForVisible('a[href="/create"]>div.linkBox')
  await app.client.click('a[href="/create"]>div.linkBox')

  // Enter passphrase twice
  await app.client.setValue('#newWallet form div:nth-child(1) input', 'test')
  await app.client.setValue('#newWallet form div:nth-child(2) input', 'test')

  // Click on generate keys button
  await app.client.click('#newWallet button[type="submit"]')

  // Verify that wallet key list is shown
  await app.client.waitForVisible('#newWallet .keyList')
  t.true(await app.client.isVisible('#newWallet .keyList'))
})

test.serial('should show wallet passphrase', async t => {
  t.true(await app.client.isVisible('#newWallet .keyListItem:nth-child(1) .key'))
  const passphraseText = await app.client.getText('#newWallet .keyListItem:nth-child(1) .key');
  t.truthy(passphraseText.length)
})

test.serial('should show wallet public address', async t => {
  t.true(await app.client.isVisible('#newWallet .keyListItem:nth-child(3) .key'))
  const publicAddressText = await app.client.getText('#newWallet .keyListItem:nth-child(3) .key');
  t.truthy(publicAddressText.length)
})

test.serial('should show wallet encrypted key', async t => {
  t.true(await app.client.isVisible('#newWallet .keyListItem:nth-child(4) .key'))
  const encryptedKeyText = await app.client.getText('#newWallet .keyListItem:nth-child(4) .key');
  t.truthy(encryptedKeyText.length)
})

test.serial('should show wallet private key', async t => {
  t.true(await app.client.isVisible('#newWallet .keyListItem:nth-child(5) .key'))
  const privateKeyText = await app.client.getText('#newWallet .keyListItem:nth-child(5) .key');
  t.truthy(privateKeyText.length)
})