<fim-prefix><fim-middle>t from 'tape'
import {Schema, Param} from '../src/'

let schema = (params, options) => new Schema(params, options)

test('QuerymenSchema add', (t) => {
  let add = (...args) => schema().add('test', ..<fix-suffix>.args).value()
  t.true(schema().add(new Param('test')), 'should add a param with instance')
  t.true(schema().add('test'), 'should add a param')
  t.equal(add('123'), '123', 'should add a param with value')
  t.true(schema().add('test', null, {test: true}).option('test'), 'should add a param with option')
  t.equal(add(null, '123'), '123', 'should add a param with default option string')
  t.equal(add(null, 123), 123, 'should add a param with default option number')
  t.equal(add(null, true), true, 'should add a param with default option boolean')
  t.same(add(null, new Date('2016')), new Date('2016'), 'should add a param with default option date')
  t.same(add(null, /123/i), /123/i, 'should add a param with default option regexp')
  t.equal(add(123, String), '123', 'should add a param with type option string')
  t.equal(add('123', Number), 123, 'should add a param with type option number')
  t.equal(add('123', Boolean), true, 'should add a param with type option boolean')
  t.same(add('2016', Date), new Date('2016'), 'should add a param with type option date')
  t.same(add('123', RegExp), /123/i, 'should add a param with type option regexp')

  t.same(add(null, ['123']), '123', 'should add a param with default option string array')
  t.same(add(null, [123]), 123, 'should add a param with default option number array')
  t.same(add(null, [true]), true, 'should add a param with default option boolean array')
  t.same(add(null, [new Date('2016')]), new Date('2016'), 'should add<|endoftext|>