Blame view

node_modules/bootstrap-vue/src/components/navbar/navbar-brand.spec.js 1.19 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
import { mount } from '@vue/test-utils'
import { BNavbarBrand } from './navbar-brand'

describe('navbar-brand', () => {
  it('default has tag "div"', async () => {
    const wrapper = mount(BNavbarBrand)

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

    wrapper.destroy()
  })

  it('default has class "navbar-brand"', async () => {
    const wrapper = mount(BNavbarBrand)

    expect(wrapper.classes()).toContain('navbar-brand')
    expect(wrapper.classes().length).toBe(1)

    wrapper.destroy()
  })

  it('accepts custom tag', async () => {
    const wrapper = mount(BNavbarBrand, {
      context: {
        props: { tag: 'span' }
      }
    })

    expect(wrapper.element.tagName).toBe('SPAN')
    expect(wrapper.classes()).toContain('navbar-brand')
    expect(wrapper.classes().length).toBe(1)

    wrapper.destroy()
  })

  it('renders link when href set', async () => {
    const wrapper = mount(BNavbarBrand, {
      context: {
        props: { href: '#foo' }
      }
    })

    expect(wrapper.element.tagName).toBe('A')
    expect(wrapper.attributes('href')).toBe('#foo')
    expect(wrapper.classes()).toContain('navbar-brand')
    expect(wrapper.classes().length).toBe(1)

    wrapper.destroy()
  })
})