'use strict'

//----------------------------------------------------------
// modules
//----------------------------------------------------------
// npm
import test from 'ava'

// local
import utils from '../lib/utils'

//----------------------------------------------------------
// tests
//----------------------------------------------------------
// header

// shift
//----------------------------------------------------------
test('shift', t => t.same(
  utils.shift(['a', 'b', 'c'])
  , ['a', ['b', 'c']]
))

// readJson

// buildCmdFn
//----------------------------------------------------------
// test('build cmd fn', t => {
//   const fn = utils.buildCmdFn(['test'])
  
// })

// parseCmd
//----------------------------------------------------------

'use strict'

//----------------------------------------------------------
// modules
//----------------------------------------------------------
// node
import child from 'child_process'

// npm
import test from 'ava'
import sinon from 'sinon'

// local
import utils from '../lib/utils'

//----------------------------------------------------------
// tests
//----------------------------------------------------------
// header

// shift
//----------------------------------------------------------
test('shift', t => t.same(
  utils.shift(['a', 'b', 'c'])
  , ['a', ['b', 'c']]
))

// readJson

// buildCmdFn
//----------------------------------------------------------
test('buildCmdFn - no args', t => {
  // prep
  sinon.stub(child, 'spawn')
  const cmd = ['test']

  // test
  utils.buildCmdFn(cmd)()
  t.same(child.spawn.args[0], ['test', {stdio: 'inherit'}])

  // cleanup
  child.spawn.restore()
})

test('buildCmdFn - with args', t => {
  // prep
  sinon.stub(child, 'spawn')
  const cmd = ['test', ['--foo', '--bar']]

  // test
  utils.buildCmdFn(cmd)()
  t.same(child.spawn.args[0], cmd.concat({stdio: 'inherit'}))

  // cleanup
  child.spawn.restore()
})

// parseCmd
//----------------------------------------------------------

write tests fro utils.buildCmdFn