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

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