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

91.67% Statements 11/12
100% Branches 0/0
80% Functions 4/5
91.67% Lines 11/12
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                                                         
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 Nav from '../../src/nav/nav'
import NavItem from '../../src/nav/navItem'
import SubNav from '../../src/nav/subNav'
 
Vue.component('am-nav', Nav)
Vue.component('am-nav-item', NavItem)
 
describe('NavItem', () => {
  it('navItem.vue 存在.', () => {
    expect(NavItem).to.be.ok
  })
  describe('props', () => {
    it('可以设置 name.', () => {
      const Component = {
        inject: ['root'],
        template: `
          <am-nav-item name="music">
            <div>nav 1</div>
          </am-nav-item>
        `
      }
      const wrapper = shallowMount(Component, {
        provide: {
          root() {
            return { root: this }
          }
        }
      })
      expect(wrapper.find('[name="music"]').exists()).to.be.true
    })
  })
})