Files
laravel-nuxt-ui-inertia-tem…/resources/js/components/common/__tests__/ErrorBoundary.test.ts

35 lines
895 B
TypeScript

import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import ErrorBoundary from '../ErrorBoundary.vue'
// Stub UIcon and UButton since they come from Nuxt UI
const stubs = {
UIcon: { template: '<span />' },
UButton: { template: '<button><slot /></button>' },
}
describe('errorBoundary', () => {
it('renders slot content when no error', () => {
const wrapper = mount(ErrorBoundary, {
slots: {
default: '<div>Hello World</div>',
},
global: { stubs },
})
expect(wrapper.text()).toContain('Hello World')
})
it('does not show error UI by default', () => {
const wrapper = mount(ErrorBoundary, {
slots: {
default: '<div>Content</div>',
},
global: { stubs },
})
expect(wrapper.text()).not.toContain('Something went wrong')
expect(wrapper.text()).toContain('Content')
})
})