From 4187be36f8d7ef86f64ec7c5857651025bbb1cea Mon Sep 17 00:00:00 2001 From: mnenie <121057011+mneniee@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:49:18 +0300 Subject: [PATCH] feat: add test for entities, fix: types in forms --- .../ui/__tests__/BoardPreviewCard.spec.ts | 62 +++++++++++++++++++ .../board/ui/__tests__/CardItem.spec.ts | 34 ++++++++++ .../board/ui/__tests__/ColumnItem.spec.ts | 50 +++++++++++++++ .../BoardPreviewCard.spec.ts.snap | 23 +++++++ .../__snapshots__/CardItem.spec.ts.snap | 49 +++++++++++++++ .../__snapshots__/ColumnItem.spec.ts.snap | 58 +++++++++++++++++ .../chart/ui/__tests__/ChartItem.spec.ts | 50 +++++++++++++++ .../__snapshots__/ChartItem.spec.ts.snap | 11 ++++ .../ui/__tests__/TemplateItem.spec.ts | 38 ++++++++++++ .../__snapshots__/TemplateItem.spec.ts.snap | 14 +++++ .../user/ui/__tests__/UserAvatar.spec.ts | 15 +++++ .../__snapshots__/UserAvatar.spec.ts.snap | 3 + src/features/auth/ui/SignInForm.vue | 4 +- src/features/auth/ui/SignUpForm.vue | 4 +- .../boards/add-board/ui/FormCreation.vue | 2 +- .../kanban/ui/add-column/FormCreation.vue | 2 +- src/shared/ui/badge/__tests__/UiBadge.spec.ts | 8 +-- .../ui/button/__tests__/UiButton.spec.ts | 10 +-- .../ui/dropdown/__tests__/UiDropdown.spec.ts | 7 ++- src/shared/ui/input/__tests__/UiInput.spec.ts | 4 +- .../__tests__/UiProgressBar.spec.ts | 4 +- .../__tests__/UiRadioGroup.spec.ts | 4 +- .../ui/select/__tests__/UiSelect.spec.ts | 5 +- src/shared/ui/sheet/__tests__/UiSheet.spec.ts | 7 ++- 24 files changed, 439 insertions(+), 29 deletions(-) create mode 100644 src/entities/board/ui/__tests__/BoardPreviewCard.spec.ts create mode 100644 src/entities/board/ui/__tests__/CardItem.spec.ts create mode 100644 src/entities/board/ui/__tests__/ColumnItem.spec.ts create mode 100644 src/entities/board/ui/__tests__/__snapshots__/BoardPreviewCard.spec.ts.snap create mode 100644 src/entities/board/ui/__tests__/__snapshots__/CardItem.spec.ts.snap create mode 100644 src/entities/board/ui/__tests__/__snapshots__/ColumnItem.spec.ts.snap create mode 100644 src/entities/chart/ui/__tests__/ChartItem.spec.ts create mode 100644 src/entities/chart/ui/__tests__/__snapshots__/ChartItem.spec.ts.snap create mode 100644 src/entities/template/ui/__tests__/TemplateItem.spec.ts create mode 100644 src/entities/template/ui/__tests__/__snapshots__/TemplateItem.spec.ts.snap create mode 100644 src/entities/user/ui/__tests__/UserAvatar.spec.ts create mode 100644 src/entities/user/ui/__tests__/__snapshots__/UserAvatar.spec.ts.snap diff --git a/src/entities/board/ui/__tests__/BoardPreviewCard.spec.ts b/src/entities/board/ui/__tests__/BoardPreviewCard.spec.ts new file mode 100644 index 00000000..3635ee90 --- /dev/null +++ b/src/entities/board/ui/__tests__/BoardPreviewCard.spec.ts @@ -0,0 +1,62 @@ +import { describe, it, expect, vi } from 'vitest'; +import { mount } from '@vue/test-utils'; +import i18n from '@/shared/lib/i18n'; +import BoardPreviewCard from '../BoardPreviewCard.vue'; + +// TODO: think about putting this mock in /shared/vitest-utils maybe +// so, the problem - is often used in many tests +vi.mock('@vueuse/integrations/useCookies', () => { + return { + useCookies: () => ({ + get: (key: string) => { + return key === 'i18n' ? 'en-US' : undefined; + } + }) + }; +}); + +const mockRouter = { + push: vi.fn(), + beforeEach: vi.fn() +}; + +describe('tests for BoardPreviewCard.vue', () => { + const wrapper = mount(BoardPreviewCard, { + global: { + plugins: [i18n], + + mocks: { + t: (key: string) => { + const translations: Record = { + 'boards.card.date_updated': 'Date Updated (test)' + }; + return translations[key]; + }, + $router: mockRouter + } + }, + props: { + board: { + _id: '0', + title: 'test title', + description: 'test description', + users: [] + } + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); + + it('should correctly works with i18n', () => { + const date = wrapper.find('.bottom_part'); + expect(date.text()).toContain('Date Updated (test)'); + }); + + it('should redirect to "/board/1" ', async () => { + await wrapper.find('.active_board').trigger('click'); + expect(mockRouter.push).toHaveBeenCalledTimes(1); + expect(mockRouter.push).toHaveBeenCalledWith('/board/1'); + }); +}); diff --git a/src/entities/board/ui/__tests__/CardItem.spec.ts b/src/entities/board/ui/__tests__/CardItem.spec.ts new file mode 100644 index 00000000..ee48389f --- /dev/null +++ b/src/entities/board/ui/__tests__/CardItem.spec.ts @@ -0,0 +1,34 @@ +import { describe, it, expect } from 'vitest'; +import { mount } from '@vue/test-utils'; +import CardItem from '../CardItem.vue'; + +describe('tests for CardItem.vue', () => { + const wrapper = mount(CardItem, { + props: { + card: { + _id: '0', + title: 'Test Card', + priority: 'low', + users: [], + chat: true, + chatCount: 2, + tags: [{ _id: '0', name: 'test' }] + } + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); + + it('should has correct number of tags', () => { + const tags = wrapper.findAll('.tags > .badge'); + expect(tags.length).toBe(1); + expect(tags[0].text()).toBe('test'); + }); + + it('should has correct chat counts', () => { + const chat = wrapper.find('.messages > span'); + expect(chat.text()).toBe('2'); + }); +}); diff --git a/src/entities/board/ui/__tests__/ColumnItem.spec.ts b/src/entities/board/ui/__tests__/ColumnItem.spec.ts new file mode 100644 index 00000000..2e27509d --- /dev/null +++ b/src/entities/board/ui/__tests__/ColumnItem.spec.ts @@ -0,0 +1,50 @@ +import { describe, expect, it, vi } from 'vitest'; +import { mount } from '@vue/test-utils'; +import ColumnItem from '../ColumnItem.vue'; +import i18n from '@/shared/lib/i18n'; + +vi.mock('@vueuse/integrations/useCookies', () => { + return { + useCookies: () => ({ + get(key: string) { + return key === 'i18n' ? 'en-US' : undefined; + } + }) + }; +}); + +describe('tests for ColumnItem.vue', () => { + const wrapper = mount(ColumnItem, { + global: { + plugins: [i18n], + mocks: { + t: (key: string) => { + const translations: Record = { + 'kanban.cards.add': 'Add card (test)' + }; + return translations[key]; + } + } + }, + props: { + column: { + _id: '0', + title: 'test', + cards: [] + } + }, + slots: { + default: 'test name of column', + content: 'test content' + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); + + it('should correctly works with i18n', () => { + const date = wrapper.find('.add'); + expect(date.text()).toContain('Add card (test)'); + }); +}); diff --git a/src/entities/board/ui/__tests__/__snapshots__/BoardPreviewCard.spec.ts.snap b/src/entities/board/ui/__tests__/__snapshots__/BoardPreviewCard.spec.ts.snap new file mode 100644 index 00000000..54034d84 --- /dev/null +++ b/src/entities/board/ui/__tests__/__snapshots__/BoardPreviewCard.spec.ts.snap @@ -0,0 +1,23 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for BoardPreviewCard > should render correctly 1`] = ` +"
+
+

test title

test description +
+
Date Updated (test): May 2024 +
+
+
" +`; + +exports[`tests for BoardPreviewCard.vue > should render correctly 1`] = ` +"
+
+

test title

test description +
+
Date Updated (test): May 2024 +
+
+
" +`; diff --git a/src/entities/board/ui/__tests__/__snapshots__/CardItem.spec.ts.snap b/src/entities/board/ui/__tests__/__snapshots__/CardItem.spec.ts.snap new file mode 100644 index 00000000..607fd4a1 --- /dev/null +++ b/src/entities/board/ui/__tests__/__snapshots__/CardItem.spec.ts.snap @@ -0,0 +1,49 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for CardItem > should render correctly 1`] = ` +"
+
+
Test Card
+
+
test
+
+
+
+
#0 +
+ + + 2
+
+
+
+
+
+
+
+
" +`; + +exports[`tests for CardItem.vue > should render correctly 1`] = ` +"
+
+
Test Card
+
+
test
+
+
+
+
#0 +
+ + + 2
+
+
+
+
+
+
+
+
" +`; diff --git a/src/entities/board/ui/__tests__/__snapshots__/ColumnItem.spec.ts.snap b/src/entities/board/ui/__tests__/__snapshots__/ColumnItem.spec.ts.snap new file mode 100644 index 00000000..bf20550b --- /dev/null +++ b/src/entities/board/ui/__tests__/__snapshots__/ColumnItem.spec.ts.snap @@ -0,0 +1,58 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`test ColumnItem > should render correctly 1`] = ` +"
+
+
test name of column0
+ + + + +
+
test content
+
+
+ + + Add card (test)
+
+
" +`; + +exports[`tests for ColumnItem > should render correctly 1`] = ` +"
+
+
test name of column0
+ + + + +
+
test content
+
+
+ + + Add card (test)
+
+
" +`; + +exports[`tests for ColumnItem.vue > should render correctly 1`] = ` +"
+
+
test name of column0
+ + + + +
+
test content
+
+
+ + + Add card (test)
+
+
" +`; diff --git a/src/entities/chart/ui/__tests__/ChartItem.spec.ts b/src/entities/chart/ui/__tests__/ChartItem.spec.ts new file mode 100644 index 00000000..b0010ccd --- /dev/null +++ b/src/entities/chart/ui/__tests__/ChartItem.spec.ts @@ -0,0 +1,50 @@ +import { describe, it, expect, vi } from 'vitest'; +import { shallowMount } from '@vue/test-utils'; +import ChartItem from '../ChartItem.vue'; +import { defineComponent, h } from 'vue'; +import i18n from '@/shared/lib/i18n'; + +vi.mock('@vueuse/integrations/useCookies', () => { + return { + useCookies: () => ({ + get(key: string) { + return key === 'i18n' ? 'en-US' : undefined; + } + }) + }; +}); + +const TestChartComponent = defineComponent({ + render() { + return h('div', 'chart'); + } +}); + +describe('tests for ChartItem.vue ', () => { + const wrapper = shallowMount(ChartItem, { + global: { + plugins: [i18n], + mocks: { + t: (key: string) => { + const translations: Record = { + 'boards.chart.test1': 'test chart title', + 'boards.chart.test2': 'test chart description' + }; + return translations[key]; + } + } + }, + props: { + chart: { + id: 'test-chart', + titleKeyI18n: 'test-title', + descriptionKeyI18n: 'test-description', + chart: TestChartComponent + } + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/src/entities/chart/ui/__tests__/__snapshots__/ChartItem.spec.ts.snap b/src/entities/chart/ui/__tests__/__snapshots__/ChartItem.spec.ts.snap new file mode 100644 index 00000000..659b623a --- /dev/null +++ b/src/entities/chart/ui/__tests__/__snapshots__/ChartItem.spec.ts.snap @@ -0,0 +1,11 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for ChartItem.vue > should render correctly 1`] = ` +"
+

+

+
+ +
+
" +`; diff --git a/src/entities/template/ui/__tests__/TemplateItem.spec.ts b/src/entities/template/ui/__tests__/TemplateItem.spec.ts new file mode 100644 index 00000000..1a6cf1ec --- /dev/null +++ b/src/entities/template/ui/__tests__/TemplateItem.spec.ts @@ -0,0 +1,38 @@ +import { describe, it, expect, vi } from 'vitest'; +import { shallowMount } from '@vue/test-utils'; +import i18n from '@/shared/lib/i18n'; +import TemplateItem from '../TemplateItem.vue'; +import { _templates } from '../../config'; + +vi.mock('@vueuse/integrations/useCookies', () => { + return { + useCookies: () => ({ + get(key: string) { + return key === 'i18n' ? 'en-US' : undefined; + } + }) + }; +}); + +describe('tests for TemplateItem.vue ', () => { + const wrapper = shallowMount(TemplateItem, { + global: { + plugins: [i18n], + mocks: { + t: (key: string) => { + const translations: Record = { + 'templates.user': 'test user' + }; + return translations[key]; + } + } + }, + props: { + template: _templates[0] + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/src/entities/template/ui/__tests__/__snapshots__/TemplateItem.spec.ts.snap b/src/entities/template/ui/__tests__/__snapshots__/TemplateItem.spec.ts.snap new file mode 100644 index 00000000..2b7e020f --- /dev/null +++ b/src/entities/template/ui/__tests__/__snapshots__/TemplateItem.spec.ts.snap @@ -0,0 +1,14 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for TemplateItem.vue > should render correctly 1`] = ` +"
+
Base Kanban
+
+ +
+

Base Kanban

Create a basic project with "Base Kanban" template +
+
June 12, 2024
+
+
" +`; diff --git a/src/entities/user/ui/__tests__/UserAvatar.spec.ts b/src/entities/user/ui/__tests__/UserAvatar.spec.ts new file mode 100644 index 00000000..a5477939 --- /dev/null +++ b/src/entities/user/ui/__tests__/UserAvatar.spec.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from 'vitest'; +import { shallowMount } from '@vue/test-utils'; +import UserAvatar from '../UserAvatar.vue'; + +describe('tests for UserAvatar.vue', () => { + const wrapper = shallowMount(UserAvatar, { + slots: { + default: 'user' + } + }); + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/src/entities/user/ui/__tests__/__snapshots__/UserAvatar.spec.ts.snap b/src/entities/user/ui/__tests__/__snapshots__/UserAvatar.spec.ts.snap new file mode 100644 index 00000000..c38e27b4 --- /dev/null +++ b/src/entities/user/ui/__tests__/__snapshots__/UserAvatar.spec.ts.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tests for UserAvatar.vue > should render correctly 1`] = `"
user
"`; diff --git a/src/features/auth/ui/SignInForm.vue b/src/features/auth/ui/SignInForm.vue index d09bced0..67c3ad75 100644 --- a/src/features/auth/ui/SignInForm.vue +++ b/src/features/auth/ui/SignInForm.vue @@ -14,8 +14,8 @@ const { t } = useI18n(); const { handleSubmit, errors } = useForm({ validationSchema }); -const { value: email } = useField('email'); -const { value: password } = useField('password'); +const { value: email } = useField('email'); +const { value: password } = useField('password'); const onLogin = handleSubmit((values) => { // on login event diff --git a/src/features/auth/ui/SignUpForm.vue b/src/features/auth/ui/SignUpForm.vue index 102c3e75..ae4a3fed 100644 --- a/src/features/auth/ui/SignUpForm.vue +++ b/src/features/auth/ui/SignUpForm.vue @@ -14,8 +14,8 @@ const { t } = useI18n(); const { handleSubmit, errors } = useForm({ validationSchema }); -const { value: email } = useField('email'); -const { value: password } = useField('password'); +const { value: email } = useField('email'); +const { value: password } = useField('password'); const onRegistration = handleSubmit((values) => { // on registration event diff --git a/src/features/boards/add-board/ui/FormCreation.vue b/src/features/boards/add-board/ui/FormCreation.vue index 2557fd9f..c9c1585f 100644 --- a/src/features/boards/add-board/ui/FormCreation.vue +++ b/src/features/boards/add-board/ui/FormCreation.vue @@ -13,7 +13,7 @@ const { t } = useI18n(); const { handleSubmit, errors } = useForm({ validationSchema }); -const { value: name } = useField('name'); +const { value: name } = useField('name'); const description = ref(''); const create = handleSubmit((values) => { diff --git a/src/features/kanban/ui/add-column/FormCreation.vue b/src/features/kanban/ui/add-column/FormCreation.vue index 5c3dccb2..6da01d40 100644 --- a/src/features/kanban/ui/add-column/FormCreation.vue +++ b/src/features/kanban/ui/add-column/FormCreation.vue @@ -11,7 +11,7 @@ const { t } = useI18n(); const { handleSubmit, errors } = useForm({ validationSchema }); -const { value: name } = useField('name'); +const { value: name } = useField('name'); const createColumn = handleSubmit((values) => { // create new column diff --git a/src/shared/ui/badge/__tests__/UiBadge.spec.ts b/src/shared/ui/badge/__tests__/UiBadge.spec.ts index f63609c5..f9dfb3da 100644 --- a/src/shared/ui/badge/__tests__/UiBadge.spec.ts +++ b/src/shared/ui/badge/__tests__/UiBadge.spec.ts @@ -1,10 +1,10 @@ import { describe, it, expect } from 'vitest'; -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import UiBadge from '../UiBadge.vue'; import type { BadgeType } from '../types'; describe('UiBadge', () => { - const wrapper = mount(UiBadge, { + const wrapper = shallowMount(UiBadge, { props: { variant: 'default' } @@ -15,7 +15,7 @@ describe('UiBadge', () => { }); it('should have content at slot', () => { - const _w = mount(UiBadge, { + const _w = shallowMount(UiBadge, { slots: { default: 'badge' } @@ -26,7 +26,7 @@ describe('UiBadge', () => { it('should apply correct styles for variants', () => { const variants = ['default', 'secondary', 'outline'] as BadgeType[]; variants.forEach((variant) => { - const wrapper = mount(UiBadge, { + const wrapper = shallowMount(UiBadge, { props: { variant } diff --git a/src/shared/ui/button/__tests__/UiButton.spec.ts b/src/shared/ui/button/__tests__/UiButton.spec.ts index 0d81e3a5..21dfe703 100644 --- a/src/shared/ui/button/__tests__/UiButton.spec.ts +++ b/src/shared/ui/button/__tests__/UiButton.spec.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from 'vitest'; -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import UiButton from '../UiButton.vue'; import type { ButtonSize, ButtonType } from '../types'; describe('UiButton', () => { - const wrapper = mount(UiButton, { + const wrapper = shallowMount(UiButton, { props: { variant: 'default', size: 'md' @@ -16,7 +16,7 @@ describe('UiButton', () => { }); it('should have content at slot', () => { - const _w = mount(UiButton, { + const _w = shallowMount(UiButton, { slots: { default: 'ui button' } @@ -28,7 +28,7 @@ describe('UiButton', () => { const variants = ['default', 'secondary', 'destructive', 'ghost', 'outline', 'dashed'] as ButtonType[]; variants.forEach((variant) => { - const wrapper = mount(UiButton, { + const wrapper = shallowMount(UiButton, { props: { variant, size: 'md' @@ -42,7 +42,7 @@ describe('UiButton', () => { it('should apply correct styles for size', () => { const sizes = ['lg', 'md', 'sm'] as ButtonSize[]; sizes.forEach((size) => { - const wrapper = mount(UiButton, { + const wrapper = shallowMount(UiButton, { props: { variant: 'dashed', size diff --git a/src/shared/ui/dropdown/__tests__/UiDropdown.spec.ts b/src/shared/ui/dropdown/__tests__/UiDropdown.spec.ts index 8ec9393a..92501ad4 100644 --- a/src/shared/ui/dropdown/__tests__/UiDropdown.spec.ts +++ b/src/shared/ui/dropdown/__tests__/UiDropdown.spec.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mount } from '@vue/test-utils'; +import { nextTick } from 'vue'; import UiDropdown from '../UiDropdown.vue'; describe('UiDropdown', () => { @@ -14,7 +15,7 @@ describe('UiDropdown', () => { it('should render correctly', async () => { //@ts-expect-error instance wrapper.vm.isOpen = true; - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.html()).toMatchSnapshot(); }); @@ -25,11 +26,11 @@ describe('UiDropdown', () => { wrapper.vm.isOpen = false; trigger.trigger('click'); - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.find('.inside').exists()).toBe(true); trigger.trigger('click'); - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.find('.inside').exists()).toBe(false); }); diff --git a/src/shared/ui/input/__tests__/UiInput.spec.ts b/src/shared/ui/input/__tests__/UiInput.spec.ts index 86af3039..8d8d3260 100644 --- a/src/shared/ui/input/__tests__/UiInput.spec.ts +++ b/src/shared/ui/input/__tests__/UiInput.spec.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest'; -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import UiInput from '../UiInput.vue'; describe('UiInput', () => { - const wrapper = mount(UiInput, { + const wrapper = shallowMount(UiInput, { props: { modelValue: 'value', placeholder: 'jenda', diff --git a/src/shared/ui/progress-bar/__tests__/UiProgressBar.spec.ts b/src/shared/ui/progress-bar/__tests__/UiProgressBar.spec.ts index 1d904f80..7ae0bd45 100644 --- a/src/shared/ui/progress-bar/__tests__/UiProgressBar.spec.ts +++ b/src/shared/ui/progress-bar/__tests__/UiProgressBar.spec.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest'; -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import UiProgressBar from '../UiProgressBar.vue'; describe('UiProgressBar', () => { - const wrapper = mount(UiProgressBar); + const wrapper = shallowMount(UiProgressBar); it('should render correctly', () => { expect(wrapper.html()).toMatchSnapshot(); diff --git a/src/shared/ui/radio-group/__tests__/UiRadioGroup.spec.ts b/src/shared/ui/radio-group/__tests__/UiRadioGroup.spec.ts index 65a7114b..384cb3a0 100644 --- a/src/shared/ui/radio-group/__tests__/UiRadioGroup.spec.ts +++ b/src/shared/ui/radio-group/__tests__/UiRadioGroup.spec.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest'; -import { mount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import UiRadioGroupItem from '../UiRadioGroupItem.vue'; describe('UiRadioGroup', () => { - const wrapper = mount(UiRadioGroupItem, { + const wrapper = shallowMount(UiRadioGroupItem, { props: { inputId: 'radio-input-id', modelValue: '', diff --git a/src/shared/ui/select/__tests__/UiSelect.spec.ts b/src/shared/ui/select/__tests__/UiSelect.spec.ts index 5cde25c9..84b224b7 100644 --- a/src/shared/ui/select/__tests__/UiSelect.spec.ts +++ b/src/shared/ui/select/__tests__/UiSelect.spec.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mount } from '@vue/test-utils'; +import { nextTick } from 'vue'; import UiSelect from '../UiSelect.vue'; describe('UiSelect', () => { @@ -13,7 +14,7 @@ describe('UiSelect', () => { it('should render correctly', async () => { //@ts-expect-error instance wrapper.vm.open = true; - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.html()).toMatchSnapshot(); }); @@ -24,7 +25,7 @@ describe('UiSelect', () => { wrapper.vm.open = false; trigger.trigger('click'); - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.find('.items').exists()).toBe(true); }); diff --git a/src/shared/ui/sheet/__tests__/UiSheet.spec.ts b/src/shared/ui/sheet/__tests__/UiSheet.spec.ts index 423aacc5..78f1d7ba 100644 --- a/src/shared/ui/sheet/__tests__/UiSheet.spec.ts +++ b/src/shared/ui/sheet/__tests__/UiSheet.spec.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mount } from '@vue/test-utils'; +import { nextTick } from 'vue'; import UiSheet from '../UiSheet.vue'; describe('UiSheet', () => { @@ -25,7 +26,7 @@ describe('UiSheet', () => { it('should render correctly', async () => { // @ts-expect-error wrapper.vm.showSheet = true; - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.html()).toMatchSnapshot(); }); @@ -37,11 +38,11 @@ describe('UiSheet', () => { it('should open/close the sheet', async () => { wrapper.vm.open(); - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.find('.sheet').attributes('aria-hidden')).toBe('false'); wrapper.vm.close(); - await wrapper.vm.$nextTick(); + await nextTick(); expect(wrapper.find('.sheet').attributes('aria-hidden')).toBe('true'); }); });