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

100% Statements 32/32
100% Branches 0/0
100% Functions 9/9
100% Lines 32/32
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                                                                           
import chai, {expect} from 'chai'
import {mount} from '@vue/test-utils'
 
import GCol from '../../src/grid/gCol'
 
describe('GCol', () => {
  it('存在.', () => {
    expect(GCol).to.be.ok
  })
  describe('props', () => {
    it('可以设置span.', () => {
      const wrapper = mount(GCol, {
        propsData: {
          span: 12
        }
      })
      const {vm} = wrapper
      expect(wrapper.classes('col-12')).to.eq(true)
    })
    it('接受 offset 属性', () => {
      const wrapper = mount(GCol, {
        propsData: {
          offset: 10
        }
      })
      const {vm} = wrapper
      expect(wrapper.classes('offset-10')).to.eq(true)
    })
    it('接受 phone 属性', () => {
      const wrapper = mount(GCol, {
        propsData: {
          phone: {
            span: 1,
            offset: 2
          }
        }
      })
      const {vm} = wrapper
      expect(wrapper.classes('col-phone-1')).to.eq(true)
      expect(wrapper.classes('offset-phone-2')).to.eq(true)
    })
    it('接受 ipad 属性', () => {
      const wrapper = mount(GCol, {
        propsData: {
          ipad: {
            span: 1,
            offset: 2
          }
        }
      })
 
      const {vm} = wrapper
      expect(wrapper.classes('col-ipad-1')).to.eq(true)
      expect(wrapper.classes('offset-ipad-2')).to.eq(true)
    })
    it('接受 narrowPc 属性', () => {
      const wrapper = mount(GCol, {
        propsData: {
          narrowPc: {
            span: 1,
            offset: 2
          }
        }
      })
 
      const {vm} = wrapper
      expect(wrapper.classes('col-narrow-pc-1')).to.eq(true)
      expect(wrapper.classes('offset-narrow-pc-2')).to.eq(true)
    })
    it('接受 pc 属性', () => {
 
      const wrapper = mount(GCol, {
        propsData: {
          pc: {
            span: 1,
            offset: 2
          }
        }
      })
      const {vm} = wrapper
      expect(wrapper.classes('col-pc-1')).to.eq(true)
      expect(wrapper.classes('offset-pc-2')).to.eq(true)
    })
  })
})