/**
 * import(s)
 */

var Vue = require('../../node_modules/vue/dist/vue')
var validator = require('../../index')
var createInstance = require('./helper').createInstance


describe('minLength', function () {
  var vm, target

  before(function () {
    Vue.config.async = false
    Vue.use(validator)
  })

  after(function () {
    Vue.config.async = true
  })
  
  beforeEach(function () {
    vm = createInstance(
      '<input type="text" v-model="comment" v-validate="minLength: 4">',
      { msg: null }
    )
    target = vm._children[0]
  })


  describe('when input 3 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaa'
      vm._digest() // force update
    })

    it('should be true', function () {
      expect(target.validation.comment.minLength).to.be(true)
    })
  })


  describe('when input 4 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaaa'
      vm._digest() // force update
    })

    it('should be false', function () {
      expect(target.validation.comment.minLength).to.be(false)
    })
  })


  describe('when input 5 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaaaa'
      vm._digest() // force update
    })

    it('should be false', function () {
      expect(target.validation.comment.minLength).to.be(false)
    })
  })
})



describe('maxLength', function () {
  var vm, target

  before(function () {
    Vue.config.async = false
    Vue.use(validator)
  })

  after(function () {
    Vue.config.async = true
  })
  
  beforeEach(function () {
    vm = createInstance(
      '<input type="text" v-model="comment" v-validate="maxLength: 4">',
      { msg: null }
    )
    target = vm._children[0]
  })


  describe('when input 3 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaa'
      vm._digest() // force update
    })

    it('should be false', function () {
      expect(target.validation.comment.maxLength).to.be(false)
    })
  })


  describe('when input 4 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaaa'
      vm._digest() // force update
    })

    it('should be false', function () {
      expect(target.validation.comment.maxLength).to.be(false)
    })
  })


  describe('when input 5 length string', function () {
    beforeEach(function () {
      vm.comment = 'aaaaa'
      vm._digest() // force update
    })

    it('should be true', function () {
      expect(target.validation.comment.maxLength).to.be(true)
    })
  })
})

@@ -483,35 +483,39 @@
 : 4%22%3E',%0A      %7B 
-msg
+comment
 : null %7D%0A    )%0A 
@@ -565,34 +565,26 @@
 be('
-when input 3 length string
+boundary value - 1
 ', f
@@ -824,34 +824,22 @@
 be('
-when input 4 length string
+boundary value
 ', f
@@ -1082,34 +1082,26 @@
 be('
-when input 5 length string
+boundary value + 1
 ', f
@@ -1663,11 +1663,15 @@
   %7B 
-msg
+comment
 : nu
@@ -1733,34 +1733,26 @@
 be('
-when input 3 length string
+boundary value - 1
 ', f
@@ -1994,34 +1994,22 @@
 be('
-when input 4 length string
+boundary value
 ', f
@@ -2252,34 +2252,26 @@
 be('
-when input 5 length string
+boundary value + 1
 ', f

Refactor length spec