|
1 |
| -import { loadFixture, testVM } from '../../../tests/utils' |
| 1 | +import ListGroup from './list-group' |
| 2 | +import { mount } from '@vue/test-utils' |
2 | 3 |
|
3 | 4 | describe('list-group', async () => {
|
4 |
| - beforeEach(loadFixture(__dirname, 'list-group')) |
5 |
| - testVM() |
| 5 | + it('default should have tag div', async () => { |
| 6 | + const wrapper = mount(ListGroup) |
| 7 | + expect(wrapper.is('div')).toBe(true) |
| 8 | + }) |
| 9 | + |
| 10 | + it('default should contain only single class of list-group', async () => { |
| 11 | + const wrapper = mount(ListGroup) |
| 12 | + expect(wrapper.classes().length).toBe(1) |
| 13 | + expect(wrapper.classes()).toContain('list-group') |
| 14 | + expect(wrapper.classes()).not.toContain('list-group-flush') |
| 15 | + expect(wrapper.classes()).not.toContain('list-group-horizontal') |
| 16 | + }) |
| 17 | + |
| 18 | + it('should have tag ul then prop tag=ul', async () => { |
| 19 | + const wrapper = mount(ListGroup, { |
| 20 | + context: { |
| 21 | + props: { tag: 'ul' } |
| 22 | + } |
| 23 | + }) |
| 24 | + expect(wrapper.is('ul')).toBe(true) |
| 25 | + }) |
| 26 | + |
| 27 | + it('should have class list-group-flush when prop flush=true', async () => { |
| 28 | + const wrapper = mount(ListGroup, { |
| 29 | + context: { |
| 30 | + props: { flush: true } |
| 31 | + } |
| 32 | + }) |
| 33 | + expect(wrapper.classes().length).toBe(2) |
| 34 | + expect(wrapper.classes()).toContain('list-group') |
| 35 | + expect(wrapper.classes()).toContain('list-group-flush') |
| 36 | + expect(wrapper.classes()).not.toContain('list-group-horizontal') |
| 37 | + }) |
| 38 | + |
| 39 | + it('should have class list-group-horizontal when prop horizontal=true', async () => { |
| 40 | + const wrapper = mount(ListGroup, { |
| 41 | + context: { |
| 42 | + props: { horizontal: true } |
| 43 | + } |
| 44 | + }) |
| 45 | + expect(wrapper.classes().length).toBe(2) |
| 46 | + expect(wrapper.classes()).not.toContain('list-group-flush') |
| 47 | + expect(wrapper.classes()).toContain('list-group') |
| 48 | + expect(wrapper.classes()).toContain('list-group-horizontal') |
| 49 | + }) |
| 50 | + |
| 51 | + it('should have class list-group-horizontal-md when prop horizontal=md', async () => { |
| 52 | + const wrapper = mount(ListGroup, { |
| 53 | + context: { |
| 54 | + props: { horizontal: 'md' } |
| 55 | + } |
| 56 | + }) |
| 57 | + expect(wrapper.classes().length).toBe(2) |
| 58 | + expect(wrapper.classes()).not.toContain('list-group-flush') |
| 59 | + expect(wrapper.classes()).not.toContain('list-group-horizontal') |
| 60 | + expect(wrapper.classes()).toContain('list-group') |
| 61 | + expect(wrapper.classes()).toContain('list-group-horizontal-md') |
| 62 | + }) |
| 63 | + |
| 64 | + it('should not have class list-group-horizontal when prop horizontal=true and flush=true', async () => { |
| 65 | + const wrapper = mount(ListGroup, { |
| 66 | + context: { |
| 67 | + props: { |
| 68 | + horizontal: true, |
| 69 | + flush: true |
| 70 | + } |
| 71 | + } |
| 72 | + }) |
| 73 | + expect(wrapper.classes().length).toBe(2) |
| 74 | + expect(wrapper.classes()).not.toContain('list-group-horizontal') |
| 75 | + expect(wrapper.classes()).toContain('list-group') |
| 76 | + expect(wrapper.classes()).toContain('list-group-flush') |
| 77 | + }) |
| 78 | + |
| 79 | + it('should not have class list-group-horizontal-lg when prop horizontal=lg and flush=true', async () => { |
| 80 | + const wrapper = mount(ListGroup, { |
| 81 | + context: { |
| 82 | + props: { |
| 83 | + horizontal: 'lg', |
| 84 | + flush: true |
| 85 | + } |
| 86 | + } |
| 87 | + }) |
| 88 | + expect(wrapper.classes().length).toBe(2) |
| 89 | + expect(wrapper.classes()).not.toContain('list-group-horizontal-lg') |
| 90 | + expect(wrapper.classes()).not.toContain('list-group-horizontal') |
| 91 | + expect(wrapper.classes()).toContain('list-group') |
| 92 | + expect(wrapper.classes()).toContain('list-group-flush') |
| 93 | + }) |
| 94 | + |
| 95 | + it('should accept custom classes', async () => { |
| 96 | + const wrapper = mount(ListGroup, { |
| 97 | + context: { |
| 98 | + class: 'foobar' |
| 99 | + } |
| 100 | + }) |
| 101 | + expect(wrapper.classes().length).toBe(2) |
| 102 | + expect(wrapper.classes()).toContain('list-group') |
| 103 | + expect(wrapper.classes()).toContain('foobar') |
| 104 | + }) |
6 | 105 | })
|
0 commit comments