{"size": 1464, "ext": "js", "max_stars_repo_path": "test/unit/index-tests.js", "max_stars_repo_name": "copperinc/hydrate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unit/index-tests.js", "max_issues_repo_name": "copperinc/hydrate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/index-tests.js", "max_forks_repo_name": "copperinc/hydrate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.2380952381, "max_line_length": 71, "alphanum_fraction": 0.6024590164}
let test = require('tape')
let proxyquire = require('proxyquire')
let called = []
function caller (type, callback) {
  called.push(type)
  callback()
}
let run = {
  install: (p, callback) => caller('install', callback),
  update: (p, callback) => caller('update', callback),
}
let shared = (p, callback) => caller('shared', callback)
let hydrate = proxyquire('../../', {
  './src': run,
  './src/shared': shared,
})
process.env.CI = true // Suppresses tape issues with progress indicator

function reset () {
  called = []
}

test('sanity check', t => {
  t.plan(1)
  t.ok(hydrate, 'hydrate in scope')
})

test(`Hydrate invokes 'shared' by default`, t => {
  t.plan(2)
  hydrate({}, function done (err) {
    if (err) t.fail(err)
    else {
      t.equal(called.length, 1, 'Invoked one method')
      t.equal(called[0], 'shared', 'Invoked shared')
    }
  })
  reset()
})

test(`Hydrate invokes 'install' if specified via params`, t => {
  t.plan(2)
  hydrate({ install: true }, function done (err) {
    if (err) t.fail(err)
    else {
      t.equal(called.length, 1, 'Invoked one method')
      t.equal(called[0], 'install', 'Invoked shared')
    }
  })
  reset()
})

test(`Hydrate invokes 'update' if specified via params`, t => {
  t.plan(2)
  hydrate({ update: true }, function done (err) {
    if (err) t.fail(err)
    else {
      t.equal(called.length, 1, 'Invoked one method')
      t.equal(called[0], 'update', 'Invoked shared')
    }
  })
  reset()
})
