Download static/tests/ButtonComponent.test.ts from aletrn/samgis: direct link, hf CLI and curl.
- Browser
- Download file 970 Bytes
-
https://huggingface.co/spaces/aletrn/samgis/resolve/main/static/tests/ButtonComponent.test.ts
- Command line
-
hf download hf://spaces/aletrn/samgis/static/tests/ButtonComponent.test.ts
-
curl -L -o ButtonComponent.test.ts https://huggingface.co/spaces/aletrn/samgis/resolve/main/static/tests/ButtonComponent.test.ts
970 Bytes
| import { describe, it, expect, vi } from 'vitest' | |
| import { mount } from '@vue/test-utils' | |
| import ButtonComponent from '@/components/buttons/ButtonComponent.vue' | |
| describe('ButtonComponent', () => { | |
| it('renders slot content', () => { | |
| const wrapper = mount(ButtonComponent, { | |
| props: { click: () => {} }, | |
| slots: { default: 'Click me' }, | |
| }) | |
| expect(wrapper.find('button').text()).toBe('Click me') | |
| }) | |
| it('calls click prop on click', async () => { | |
| const clickFn = vi.fn() | |
| const wrapper = mount(ButtonComponent, { | |
| props: { click: clickFn }, | |
| slots: { default: 'Click me' }, | |
| }) | |
| await wrapper.find('button').trigger('click') | |
| expect(clickFn).toHaveBeenCalledOnce() | |
| }) | |
| it('renders HTML slot content', () => { | |
| const wrapper = mount(ButtonComponent, { | |
| props: { click: () => {} }, | |
| slots: { default: '<span>icon</span> Save' }, | |
| }) | |
| expect(wrapper.find('button span').text()).toBe('icon') | |
| }) | |
| }) | |