const expect = require('expect')
const functionReflector = require('../index')

describe('Default Parameter', () => {
  const func = (a, b = true, c = 'string', d = 5) => {
    return a
  }

  it('should return javascript object', () => {
    const actual = functionReflector(func)
    const expected = 'object'

    expect(actual).toBeAn(expected)
  })

  it('should return array of arguments', () => {
    const actual = functionReflector(func).args
    const expected = ['a', ['b', true], ['c', 'string'], ['d', 5]]

    expect(actual).toEqual(expected)
  })

  it('should parse single argument', () => {
    const singleParameterFunc = x => {}
    const actual = functionReflector(singleParameterFunc).args
    const expected = 'x'

    expect(actual).toEqual(expected)
  })

  it('should parse single argument with parenthesis', () => {
    const singleParameterFunc = (x = 'a') => {}
    const actual = functionReflector(singleParameterFunc).args
    const expected = [['x', 'a']]

    expect(actual).toEqual(expected)
  })
})

const expect = require('expect')
const functionReflector = require('../index')

describe('Default Parameter', () => {
  const func = (a, b = true, c = 'string', d = 5) => {
    return a
  }

  it('should return javascript object', () => {
    const actual = functionReflector(func)
    const expected = 'object'

    expect(actual).toBeAn(expected)
  })

  it('should return array of arguments', () => {
    const actual = functionReflector(func).args
    const expected = ['a', ['b', true], ['c', 'string'], ['d', 5]]

    expect(actual).toEqual(expected)
  })

  it('should parse single argument with parenthesis', () => {
    const singleParameterFunc = (x = 'a') => {}
    const actual = functionReflector(singleParameterFunc).args
    const expected = [['x', 'a']]

    expect(actual).toEqual(expected)
  })
})

remove unnecessary test