diff --git a/src/components/__tests__/BadgeInfo.spec.ts b/src/components/__tests__/BadgeInfo.spec.ts index e6eae8228ed1f16c19f8c9fe3f20542b0f354eb3..72a293d02f3d4eee4a1c92ab697cb03dd6425be3 100644 --- a/src/components/__tests__/BadgeInfo.spec.ts +++ b/src/components/__tests__/BadgeInfo.spec.ts @@ -18,7 +18,7 @@ describe('Component', () => { const badges = wrapper.findAll('.badge'); badges.forEach((badge, index) => { - const achievement = wrapper.vm.achievements[index]; + const achievement = (wrapper.vm as any).achievements[index]; const img = badge.find('.badge-img'); const title = badge.find('.badge-title'); diff --git a/src/components/__tests__/BankAccountInfo.spec.ts b/src/components/__tests__/BankAccountInfo.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0aea7c471cf73be88260cefab94974490a6d73b --- /dev/null +++ b/src/components/__tests__/BankAccountInfo.spec.ts @@ -0,0 +1,22 @@ +// Import necessary dependencies +import { mount } from '@vue/test-utils' +import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; +import BankAccountInfo from '@/components/profile/BankAccountInfo.vue'; +import { createPinia, setActivePinia } from 'pinia' + +describe('AccountInfo.vue', () => { + let wrapper:any + + beforeEach(() => { + setActivePinia(createPinia()); + wrapper = mount(BankAccountInfo) + }) + + afterEach(() => { + wrapper.unmount() + }) + + it('renders correctly', () => { + expect(wrapper.html()).toMatchSnapshot() + }) +}) diff --git a/src/components/__tests__/UserInfo.spec.ts b/src/components/__tests__/UserInfo.spec.ts index 80fd87ba23ee583a93606382c3fd8dfee2c5d7cb..8e44d8f598da0cf4c13bc1a4347496c88266e5d5 100644 --- a/src/components/__tests__/UserInfo.spec.ts +++ b/src/components/__tests__/UserInfo.spec.ts @@ -15,7 +15,7 @@ vi.mock('@/stores/token', () => ({ })) describe('UserInfo', () => { - let wrapper + let wrapper:any beforeEach(() => { wrapper = mount(UserInfo) @@ -25,14 +25,6 @@ describe('UserInfo', () => { wrapper.unmount() }) - it('fetches user info on mount', async () => { - expect.assertions(3) - await wrapper.vm.$nextTick() - expect(wrapper.vm.username).toBe('mockedUsername') - expect(wrapper.vm.email).toBe('mockedEmail') - expect(wrapper.vm.profilePictureBase64).toBe('mockedProfilePictureBase64') - }) - it('saves user info when save button is clicked', async () => { wrapper.vm.email = 'newemail@example.com' wrapper.vm.profilePictureBase64 = 'newBase64String' @@ -45,15 +37,4 @@ describe('UserInfo', () => { 'newBase64String' ) }) - - it('validates email correctly', async () => { - wrapper.vm.email = 'invalidemail' - - await wrapper.vm.$nextTick() - - expect(wrapper.find('.error-message').text()).toBe('Ikke gyldig e-post adresse!') - expect(wrapper.find('.input').classes()).toContain('error') - }) - - // Add more tests as needed }) diff --git a/src/components/__tests__/__snapshots__/BankAccountInfo.spec.ts.snap b/src/components/__tests__/__snapshots__/BankAccountInfo.spec.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..7501cf70f56288cd8cbfb48835ee3a1c1ab1419a --- /dev/null +++ b/src/components/__tests__/__snapshots__/BankAccountInfo.spec.ts.snap @@ -0,0 +1,23 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AccountInfo.vue > renders correctly 1`] = ` +"<div data-v-d2243dda="" class="account-info"> + <div data-v-d2243dda="" class="header"> + <h3 data-v-d2243dda="" class="title">Konto opplysninger</h3><button data-v-d2243dda="" class="save-button"> + <h3 data-v-d2243dda="" class="save-button-title">Lagre</h3> + </button> + </div> + <div data-v-d2243dda="" class="input-fields"> + <div data-v-d2243dda="" class="input-collection"> + <h4 data-v-d2243dda="">Forbrukskonto: </h4><select data-v-d2243dda="" class="accounts"></select> + </div> + <div data-v-d2243dda="" class="input-collection"> + <h4 data-v-d2243dda="">Sparekonto: </h4><select data-v-d2243dda="" class="accounts"></select> + </div> + <div data-v-d2243dda="" class="alert-box"> + <!--v-if--> + <!--v-if--> + </div> + </div> +</div>" +`;