diff --git a/src/App.vue b/src/App.vue index a0d7a19..ef16a8e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,3 @@ diff --git a/src/assets/icons/LoadingSpinner.vue b/src/assets/icons/LoadingSpinner.vue new file mode 100644 index 0000000..20c7738 --- /dev/null +++ b/src/assets/icons/LoadingSpinner.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/components/DButton.vue b/src/components/DButton.vue deleted file mode 100644 index da02763..0000000 --- a/src/components/DButton.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - diff --git a/src/components/DxhButton.vue b/src/components/DxhButton.vue new file mode 100644 index 0000000..854fe65 --- /dev/null +++ b/src/components/DxhButton.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/components/__tests__/DButton.spec.ts b/src/components/__tests__/DButton.spec.ts deleted file mode 100644 index 0ec0695..0000000 --- a/src/components/__tests__/DButton.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { mount } from '@vue/test-utils'; -import Button from '../DButton.vue'; - -describe('DButton.vue', () => { - it('emits a click event when clicked', async () => { - const wrapper = mount(Button, { - props: { - color: 'blue', - size: 'md', - }, - slots: { - default: 'Click Me', - }, - }); - - await wrapper.trigger('click'); - expect(wrapper.emitted()).toHaveProperty('click'); - }); - - it('has the correct default classes', () => { - const wrapper = mount(Button); - expect(wrapper.classes()).toContain('rounded'); - expect(wrapper.classes()).toContain('bg-blue-500'); - expect(wrapper.classes()).toContain('text-md'); - expect(wrapper.classes()).toContain('px-4'); - expect(wrapper.classes()).toContain('py-2'); - }); - - it('displays the slot content', () => { - const wrapper = mount(Button, { - slots: { - default: 'Click Me', - }, - }); - expect(wrapper.text()).toContain('Click Me'); - }); - - it('applies the size classes correctly', () => { - const wrapper = mount(Button, { - props: { - size: 'lg', - }, - }); - expect(wrapper.classes()).toContain('text-lg'); - expect(wrapper.classes()).toContain('px-6'); - expect(wrapper.classes()).toContain('py-3'); - }); - - it('applies the color classes correctly', () => { - const wrapper = mount(Button, { - props: { - color: 'red', - }, - }); - expect(wrapper.classes()).toContain('bg-red-500'); - }); -}); diff --git a/src/components/__tests__/DxhButton.spec.ts b/src/components/__tests__/DxhButton.spec.ts new file mode 100644 index 0000000..dd186bb --- /dev/null +++ b/src/components/__tests__/DxhButton.spec.ts @@ -0,0 +1,74 @@ +import { describe, it, expect } from 'vitest' +import { mount } from '@vue/test-utils' +import Button from '../DxhButton.vue' + +describe('DButton.vue', () => { + it('emits a click event when clicked', async () => { + const wrapper = mount(Button, { + props: { + name: 'Click me', + type: 'submit', + value: 'Click me' + } + }) + + await wrapper.trigger('click') + expect(wrapper.emitted()).toHaveProperty('click') + }) + + it('renders a button with the correct default classes', () => { + const wrapper = mount(Button) + expect(wrapper.classes()).toContain('border') + expect(wrapper.classes()).toContain('px-1') + expect(wrapper.classes()).toContain('pb-0.5') + }) + + it('renders a button with the correct dynamic classes', async () => { + const wrapper = mount(Button) + await wrapper.setProps({ disabled: true }) + }) + + it('displays the slot content for the button', () => { + const wrapper = mount(Button, { + slots: { + default: 'Click me' + } + }) + expect(wrapper.text()).toContain('Click me') + }) + + it('renders an anchor with the correct default classes', () => { + const wrapper = mount(Button, { + props: { + href: 'https://example.com', + target: '_blank' + } + }) + expect(wrapper.find('a').classes()).toContain('border') + expect(wrapper.find('a').classes()).toContain('px-1') + expect(wrapper.find('a').classes()).toContain('pb-0.5') + }) + + it('renders an anchor with the correct dynamic classes', async () => { + const wrapper = mount(Button, { + props: { + href: 'https://example.com', + target: '_blank' + } + }) + await wrapper.setProps({ disabled: true }) + }) + + it('displays the slot content for the anchor', () => { + const wrapper = mount(Button, { + props: { + href: 'https://example.com', + target: '_blank' + }, + slots: { + default: 'Click me' + } + }) + expect(wrapper.text()).toContain('Click me') + }) +}) diff --git a/src/index.ts b/src/index.ts index ee2ff8d..2d1e802 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import DButton from "./components/DButton.vue" +import DxhButton from './components/DxhButton.vue' import DInput from "./components/DInput.vue" -export default {DButton, DInput} \ No newline at end of file +export default { DxhButton, DInput } \ No newline at end of file