component.test.ts 676 B

1234567891011121314151617181920212223
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, it } from 'vitest'
  3. import TheCounter from '../src/components/TheCounter.vue'
  4. describe('TheCounter.vue', () => {
  5. it('should render', () => {
  6. const wrapper = mount(TheCounter, { props: { initial: 10 } })
  7. expect(wrapper.text()).toContain('10')
  8. expect(wrapper.html()).toMatchSnapshot()
  9. })
  10. it('should be interactive', async () => {
  11. const wrapper = mount(TheCounter, { props: { initial: 0 } })
  12. expect(wrapper.text()).toContain('0')
  13. expect(wrapper.find('.inc').exists()).toBe(true)
  14. await wrapper.get('button').trigger('click')
  15. expect(wrapper.text()).toContain('1')
  16. })
  17. })