Blame view

node_modules/bootstrap-vue/src/components/card/card-footer.spec.js 2.48 KB
4cd4fd28   郭伟龙   feat: 初始化项目
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
87
88
89
90
91
92
93
94
95
96
97
98
import { mount } from '@vue/test-utils'
import { BCardFooter } from './card-footer'

describe('card-footer', () => {
  it('has root element "div"', async () => {
    const wrapper = mount(BCardFooter)

    expect(wrapper.element.tagName).toBe('DIV')

    wrapper.destroy()
  })

  it('has class card-header', async () => {
    const wrapper = mount(BCardFooter)

    expect(wrapper.classes()).toContain('card-footer')
    expect(wrapper.classes().length).toBe(1)

    wrapper.destroy()
  })

  it('has custom root element when prop footerTag is set', async () => {
    const wrapper = mount(BCardFooter, {
      context: {
        props: {
          footerTag: 'footer'
        }
      }
    })

    expect(wrapper.element.tagName).toBe('FOOTER')
    expect(wrapper.classes()).toContain('card-footer')

    wrapper.destroy()
  })

  it('has class bg-info when prop footerBgVariant=info', async () => {
    const wrapper = mount(BCardFooter, {
      context: {
        props: { footerBgVariant: 'info' }
      }
    })

    expect(wrapper.classes()).toContain('card-footer')
    expect(wrapper.classes()).toContain('bg-info')
    expect(wrapper.classes().length).toBe(2)

    wrapper.destroy()
  })

  it('has class text-info when prop footerTextVariant=info', async () => {
    const wrapper = mount(BCardFooter, {
      context: {
        props: { footerTextVariant: 'info' }
      }
    })

    expect(wrapper.classes()).toContain('card-footer')
    expect(wrapper.classes()).toContain('text-info')
    expect(wrapper.classes().length).toBe(2)

    wrapper.destroy()
  })

  it('has class border-info when prop footerBorderVariant=info', async () => {
    const wrapper = mount(BCardFooter, {
      context: {
        props: { footerBorderVariant: 'info' }
      }
    })

    expect(wrapper.classes()).toContain('card-footer')
    expect(wrapper.classes()).toContain('border-info')
    expect(wrapper.classes().length).toBe(2)

    wrapper.destroy()
  })

  it('has all variant classes when all variant props set', async () => {
    const wrapper = mount(BCardFooter, {
      context: {
        props: {
          footerTextVariant: 'info',
          footerBgVariant: 'danger',
          footerBorderVariant: 'dark'
        }
      }
    })

    expect(wrapper.classes()).toContain('card-footer')
    expect(wrapper.classes()).toContain('text-info')
    expect(wrapper.classes()).toContain('bg-danger')
    expect(wrapper.classes()).toContain('border-dark')
    expect(wrapper.classes().length).toBe(4)

    wrapper.destroy()
  })
})