Skip to content

Commit

Permalink
test: add tests for welcome
Browse files Browse the repository at this point in the history
  • Loading branch information
mnenie committed Sep 2, 2024
1 parent dd957e6 commit 07163c2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/widgets/welcome/ui/__tests__/AboutSection.spec.ts
Original file line number Diff line number Diff line change
@@ -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' });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`tests for AboutSection.vue > should be render correctly 1`] = `
"<section class="container">
<div class="badge"><span style="margin-right: 3px;">✨</span><span class="text-sm">Core: Task Boards, Real-Time Tracking</span>
<anonymous-stub size="14"></anonymous-stub>
</div>
<h1>Your path to perfection</h1>
<p class="text-lg">Jenda is a cloud-based program for efficient collaborative and individual project and task management.</p>
<div class="btns">
<ui-button-stub variant="default" size="md"></ui-button-stub>
<ui-button-stub variant="outline" size="md" class="btn_git"></ui-button-stub>
</div>
</section>"
`;

exports[`tests for AboutSection.vue > should navigate correctly 1`] = `
"<section class="container">
<div class="badge"><span style="margin-right: 3px;">✨</span><span class="text-sm">Core: Task Boards, Real-Time Tracking</span>
<anonymous-stub size="14"></anonymous-stub>
</div>
<h1>Your path to perfection</h1>
<p class="text-lg">Jenda is a cloud-based program for efficient collaborative and individual project and task management.</p>
<div class="btns">
<ui-button-stub variant="default" size="md"></ui-button-stub>
<ui-button-stub variant="outline" size="md" class="btn_git"></ui-button-stub>
</div>
</section>"
`;

0 comments on commit 07163c2

Please sign in to comment.