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

100% Statements 11/11
100% Branches 0/0
100% Functions 5/5
100% Lines 11/11
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                                                                     
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 Table from '../../src/table/index'
import TableColumn from '../../src/table/tableColumn'
 
describe('Table', () => {
  it('存在.', () => {
    expect(Table).to.be.ok
  })
  describe('props', () => {
    it('可以设置 dataSource.', (done) => {
      const wrapper = mount(Table, {
        propsData: {
          dataSource: [
            {id: 1, name: '王小虎', age: 2, phone: '12345678919', address: '上海市普陀区金沙江路 1518 弄'},
            {id: 2, name: '李小', age: 10, phone: '12345678929', address: '上海市普陀区金沙江路 1518 弄'},
            {id: 3, name: '刘虎', age: 6, phone: '12345678939', address: '上海市普陀区金沙江路 1518 弄'},
            {id: 4, name: '高丽', age: 4, phone: '12345678949', address: '上海市普陀区金沙江路 1518 弄'},
            {id: 5, name: '王二', age: 14, phone: '12345678949', address: '上海市普陀区金沙江路 1518 弄'},
          ]
        },
        slots: {
          default: `
            <table-column text="姓名" field="name"></table-column>
            <table-column text="年龄" field="age"></table-column>
            <table-column text="手机" field="phone"></table-column>
            <table-column text="地址" field="address"></table-column>
          `
        }
      })
      console.log(wrapper.html());
      setTimeout(() => {
        console.log(wrapper.html());
        done()
      }, 30)
      // expect(el.attributes('href')).to.equal('#i-settings')
    })
  })
})