From 07163c2344e76670832904ae6eb99734356fb7c8 Mon Sep 17 00:00:00 2001 From: mnenie <1alexpeshkov@gmail.com> Date: Mon, 2 Sep 2024 21:51:02 +0300 Subject: [PATCH] test: add tests for welcome --- .../welcome/ui/__tests__/AboutSection.spec.ts | 32 +++++++++++++++++++ .../__snapshots__/AboutSection.spec.ts.snap | 29 +++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/widgets/welcome/ui/__tests__/AboutSection.spec.ts create mode 100644 src/widgets/welcome/ui/__tests__/__snapshots__/AboutSection.spec.ts.snap diff --git a/src/widgets/welcome/ui/__tests__/AboutSection.spec.ts b/src/widgets/welcome/ui/__tests__/AboutSection.spec.ts new file mode 100644 index 00000000..86d38b16 --- /dev/null +++ b/src/widgets/welcome/ui/__tests__/AboutSection.spec.ts @@ -0,0 +1,32 @@ +import { describe, it, expect, vi } from 'vitest'; +import { shallowMount } from '@vue/test-utils'; +import '@/shared/lib/vitest-utils/cookiesI18n-mock'; +import AboutSection from '../AboutSection.vue'; +import i18n from '@/shared/lib/i18n'; +import { UiButton } from '@/shared/ui'; + +const mockRouter = { + push: vi.fn(), + beforeEach: vi.fn() +}; + +describe('tests for AboutSection.vue', () => { + const wrapper = shallowMount(AboutSection, { + global: { + plugins: [i18n], + mocks: { + $router: mockRouter + } + } + }); + + it('should be render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); + + it('should redirect correctly ', async () => { + const btn = wrapper.find('.btns').findAllComponents(UiButton).at(0); + await btn.trigger('click'); + expect(mockRouter.push).toHaveBeenCalledWith({ name: 'registration' }); + }); +}); diff --git a/src/widgets/welcome/ui/__tests__/__snapshots__/AboutSection.spec.ts.snap b/src/widgets/welcome/ui/__tests__/__snapshots__/AboutSection.spec.ts.snap new file mode 100644 index 00000000..b153b477 --- /dev/null +++ b/src/widgets/welcome/ui/__tests__/__snapshots__/AboutSection.spec.ts.snap @@ -0,0 +1,29 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for AboutSection.vue > should be render correctly 1`] = ` +"
+
Core: Task Boards, Real-Time Tracking + +
+

Your path to perfection

+

Jenda is a cloud-based program for efficient collaborative and individual project and task management.

+
+ + +
+
" +`; + +exports[`tests for AboutSection.vue > should navigate correctly 1`] = ` +"
+
Core: Task Boards, Real-Time Tracking + +
+

Your path to perfection

+

Jenda is a cloud-based program for efficient collaborative and individual project and task management.

+
+ + +
+
" +`;