all files / tests/unit/ collapseItem.spec.js

100% Statements 16/16
100% Branches 0/0
100% Functions 6/6
100% Lines 16/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                               
import chai, { expect } from 'chai'
import sinon from 'sinon'
import sinonChai from 'sinon-chai'
chai.use(sinonChai)
import { mount, shallowMount } from '@vue/test-utils'
 
import Vue from 'vue'
import CollapseItem from '../../src/collapse/collapseItem'
 
describe('CollapseItem', done => {
  it('存在.', () => {
    expect(CollapseItem).to.be.ok
  })
  it('可以设置 name.', () => {
    const wrapper = mount(CollapseItem, {
      propsData: {
        name: 'test1',
        title: 'title oo'
      }
    })
    expect(wrapper.find('[data-name="test1"]').exists()).to.be.true
  })
  it('visibleIcon 默认为true.', () => {
    const wrapper = mount(CollapseItem, {
      inject: ['eventBus'],
      propsData: {
        name: 'test1',
        title: 'title oo'
      }
    })
    expect(wrapper.find('.am-icon-animation').exists()).to.be.true
  })
  it('可以设置 visibleIcon.', () => {
    const wrapper = mount(CollapseItem, {
      inject: ['eventBus'],
      propsData: {
        name: 'test1',
        title: 'title oo',
        visibleIcon: false
      }
    })
    expect(wrapper.find('.am-icon-animation').exists()).to.be.false
  })
  it('可以设置 title.', () => {
    const wrapper = mount(CollapseItem, {
      propsData: {
        name: 'test1',
        title: 'title oo'
      }
    })
    expect(
      wrapper.find('.am-collapse-item-name[data-name="test1"]').text()
    ).to.be.eq('title oo')
  })
})