<commit_before>import { mount } from '@vue/test-utils'
import Checkbox from '@/components/Checkbox'

describe('components/Checkbox', () => {
  it('should handle checked prop with `null` value.', done => {
    let wrapper = mount(Checkbox, {
      propsData: {
        checked: null
      }
    })

    wrapper.vm.$on('change', val => {
      expect(val).to.be.equal(true)

      wrapper.destroy()
      done()
    })

    wrapper.find('input').trigger('change')
  })

  it('should update checked/model value before change event is fired.', done => {
    let wrapper = mount({
      components: {
        'veui-checkbox': Checkbox
      },
      data () {
        return {
          choice: 'YES'
        }
      },
      methods: {
        handleChange (checked) {
          expect(checked).to.be.equal(false)
          expect(this.choice).to.be.equal('NO')

          wrapper.destroy()
          done()
        }
      },
      template:
        '<veui-checkbox v-model="choice" true-value="YES" false-value="NO" @change="handleChange"/>'
    })

    wrapper.find('input').trigger('change')
  })
})<commit_msg>test: add test case of checkbox component (#448)<commit_after>import { mount } from '@vue/test-utils'
import Checkbox from '@/components/Checkbox'

describe('components/Checkbox', () => {
  it('should handle checked prop with `null` value.', done => {
    let wrapper = mount(Checkbox, {
      propsData: {
        checked: null
      }
    },
    {
      sync: false
    })

    wrapper.vm.$on('change', val => {
      expect(val).to.be.equal(true)

      wrapper.destroy()
      done()
    })

    wrapper.find('input').trigger('change')
  })

  it('should update checked/model value before change event is fired.', done => {
    let wrapper = mount({
      components: {
        'veui-checkbox': Checkbox
      },
      data () {
        return {
          choice: 'YES'
        }
      },
      methods: {
        handleChange (checked) {
          expect(checked).to.be.equal(false)
          expect(this.choice).to.be.equal('NO')

          wrapper.destroy()
          done()
        }
      },
      template:
        '<veui-checkbox v-model="choice" true-value="YES" false-value="NO" @change="handleChange"/>'
    },
    {
      sync: false
    })

    wrapper.find('input').trigger('change')
  })

  it('should support v-model array', async () => {
    let wrapper = mount(
      {
        components: {
          'veui-checkbox': Checkbox
        },
        data () {
          return {
            group: ['A']
          }
        },
        template:
          `<div>
            <veui-checkbox v-model="group" value="A"> A </veui-checkbox>
            <veui-checkbox v-model="group" value="B"> B </veui-checkbox>
            <veui-checkbox v-model="group" value="C"> C </veui-checkbox>
          </div>`
      },
      {
        sync: false
      }
    )

    let boxes = wrapper.findAll('input')
    boxes.at(0).trigger('change')
    boxes.at(2).trigger('change')

    let { vm } = wrapper
    await vm.$nextTick()

    expect(vm.group).to.deep.equal(['A', 'C'])

    wrapper.destroy()
  })

  it('should handle correctly when activated', () => {
    let wrapper = mount(Checkbox, {
      propsData: {
        checked: false
      }
    },
    {
      sync: false
    })

    wrapper.vm.$on('change', val => {
      expect(val).to.be.equal(true)
    })

    wrapper.vm.activate()
  })
})
{'fraction_non_alphanumeric': 0.16354044548651817, 'fraction_numerical': 0.0014654161781946073, 'mean_word_length': 1.934651762682717, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625900', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1023, 'n_words': 202}