|
| 1 | +import { describe, expect, test } from 'vitest' |
| 2 | +import { mount } from '@vue/test-utils' |
| 3 | +import MyPanel from '../MyPanel.vue' |
| 4 | + |
| 5 | +describe('MyPanel', () => { |
| 6 | + test('Just a body', () => { |
| 7 | + const wrapper = mount(MyPanel) |
| 8 | + |
| 9 | + expect(wrapper.findAll('.panel-section')).toHaveLength(1) |
| 10 | + expect(wrapper.findAll('.panel-body')).toHaveLength(1) |
| 11 | + expect(wrapper.findAll('.panel-footer')).toHaveLength(0) |
| 12 | + expect(wrapper.findAll('.panel-header')).toHaveLength(0) |
| 13 | + }) |
| 14 | + |
| 15 | + test('title prop', () => { |
| 16 | + const wrapper = mount(MyPanel, { |
| 17 | + props: { |
| 18 | + title: 'Title' |
| 19 | + } |
| 20 | + }) |
| 21 | + |
| 22 | + expect(wrapper.findAll('.panel-section')).toHaveLength(2) |
| 23 | + expect(wrapper.findAll('.panel-body')).toHaveLength(1) |
| 24 | + expect(wrapper.findAll('.panel-footer')).toHaveLength(0) |
| 25 | + expect(wrapper.findAll('.panel-header')).toHaveLength(1) |
| 26 | + |
| 27 | + expect(wrapper.get('.panel-header').text()).toBe('Title') |
| 28 | + }) |
| 29 | + |
| 30 | + test('footer prop', () => { |
| 31 | + const wrapper = mount(MyPanel, { |
| 32 | + props: { |
| 33 | + footer: 'Footer' |
| 34 | + } |
| 35 | + }) |
| 36 | + |
| 37 | + expect(wrapper.findAll('.panel-section')).toHaveLength(2) |
| 38 | + expect(wrapper.findAll('.panel-body')).toHaveLength(1) |
| 39 | + expect(wrapper.findAll('.panel-footer')).toHaveLength(1) |
| 40 | + expect(wrapper.findAll('.panel-header')).toHaveLength(0) |
| 41 | + |
| 42 | + expect(wrapper.get('.panel-footer').text()).toBe('Footer') |
| 43 | + }) |
| 44 | + |
| 45 | + test('title and footer props', () => { |
| 46 | + const wrapper = mount(MyPanel, { |
| 47 | + props: { |
| 48 | + title: 'Both title', |
| 49 | + footer: 'and footer' |
| 50 | + } |
| 51 | + }) |
| 52 | + |
| 53 | + expect(wrapper.findAll('.panel-section')).toHaveLength(3) |
| 54 | + expect(wrapper.findAll('.panel-body')).toHaveLength(1) |
| 55 | + expect(wrapper.findAll('.panel-footer')).toHaveLength(1) |
| 56 | + expect(wrapper.findAll('.panel-header')).toHaveLength(1) |
| 57 | + |
| 58 | + expect(wrapper.get('.panel-header').text()).toBe('Both title') |
| 59 | + expect(wrapper.get('.panel-footer').text()).toBe('and footer') |
| 60 | + }) |
| 61 | +}) |
0 commit comments