Skip to content

Commit

Permalink
resolves: #40
Browse files Browse the repository at this point in the history
  • Loading branch information
mnenie committed Aug 25, 2024
1 parent 045e697 commit fee405f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ describe('tests for ThemeSwitcher.vue', () => {
expect(wrapper.html()).toMatchSnapshot();
});
it('should render subcomponents', () => {
// TODO: change `findComponent` selector -> name in another tests
// So the problem with component import is solved ✅
expect(wrapper.findComponent({ name: 'UiRadioGroupContainer' }).exists()).toBe(true);
expect(wrapper.findComponent({ name: 'UiButton' }).exists()).toBe(true);
});
Expand Down
3 changes: 1 addition & 2 deletions src/pages/__tests__/NotFound.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { shallowMount } from '@vue/test-utils';
import { describe, it, expect, vi } from 'vitest';
import NotFound from '../NotFoundPage.vue';
import { useHead } from '@unhead/vue';
import { UiButton } from '@/shared/ui';

vi.mock('@unhead/vue', () => ({
useHead: vi.fn()
Expand Down Expand Up @@ -33,7 +32,7 @@ describe('tests for NotFoundPage.vue', () => {
});

it('should redirect correctly', async () => {
await wrapper.findComponent(UiButton).trigger('click');
await wrapper.findComponent({ name: 'UiButton' }).trigger('click');
expect(mockRouter.push).toHaveBeenCalledWith({ name: 'boards' });
});
});
9 changes: 4 additions & 5 deletions src/widgets/layout/ui/header/__tests__/HeaderWelcome.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { nextTick } from 'vue';
import '@/shared/lib/vitest-utils/cookiesI18n-mock';
import HeaderWelcome from '../HeaderWelcome.vue';
import i18n from '@/shared/lib/i18n';
import { UiButton, UiSelect } from '@/shared/ui';
import { Moon, Sun } from 'lucide-vue-next';

const mockRouter = {
Expand Down Expand Up @@ -41,8 +40,8 @@ describe('tests for HeaderWelcome.vue', () => {
});

it('should render subcomponents', () => {
expect(wrapper.findComponent(UiButton).exists()).toBe(true);
expect(wrapper.findComponent(UiSelect).exists()).toBe(true);
expect(wrapper.findComponent({ name: 'UiButton' }).exists()).toBe(true);
expect(wrapper.findComponent({ name: 'UiSelect' }).exists()).toBe(true);
});

it('should handle mode + icon changing', async () => {
Expand All @@ -62,14 +61,14 @@ describe('tests for HeaderWelcome.vue', () => {
});

it('should redirect correctly to login', async () => {
const loginButton = wrapper.find('.btns').findAllComponents(UiButton).at(0);
const loginButton = wrapper.find('.btns').findAllComponents({ name: 'UiButton' }).at(0);

await loginButton.trigger('click');
expect(mockRouter.push).toHaveBeenCalledWith({ name: 'login' });
});

it('should redirect correctly to registration', async () => {
const registrationButton = wrapper.find('.btns').findAllComponents(UiButton).at(1);
const registrationButton = wrapper.find('.btns').findAllComponents({ name: 'UiButton' }).at(1);

await registrationButton.trigger('click');
expect(mockRouter.push).toHaveBeenCalledWith({ name: 'registration' });
Expand Down

0 comments on commit fee405f

Please sign in to comment.