diff --git a/src/components/__tests__/PasswordInfo.spec.ts b/src/components/__tests__/PasswordInfo.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8e6d79ed7346ef47adb6e1b3c71fe1c136267b6 --- /dev/null +++ b/src/components/__tests__/PasswordInfo.spec.ts @@ -0,0 +1,25 @@ +import { mount } from '@vue/test-utils' +import PasswordInfo from '@/components/profile/PasswordInfo.vue' +import { describe, it, expect, beforeEach } from 'vitest' +import { createPinia, setActivePinia } from 'pinia' + +describe('PasswordComponent', () => { + + beforeEach(() => { + setActivePinia(createPinia()); + }); + + it('renders correctly', async () => { + const wrapper = mount(PasswordInfo) + + expect(wrapper.exists()).toBe(true) + + expect(wrapper.find('.title').text()).toBe('Passord') + + expect(wrapper.find('.save-button').exists()).toBe(true) + + expect(wrapper.find('[data-testid="current-password-input"]').exists()).toBe(true) + + expect(wrapper.find('[data-testid="new-password-input"]').exists()).toBe(true) + }) +}) diff --git a/src/components/profile/PasswordInfo.vue b/src/components/profile/PasswordInfo.vue index dff3599bed71b23e98712a462bb0daf84fd9226e..29dbbceb5ec22b7b014c0c79be4a6301d7de79a0 100644 --- a/src/components/profile/PasswordInfo.vue +++ b/src/components/profile/PasswordInfo.vue @@ -73,7 +73,8 @@ const clearInput = () => { <input class="input" :class="{'error': currentPasswordError}" type="password" - v-model="currentPassword"> + v-model="currentPassword" + data-testid="current-password-input"> <div class="alert-box"> <h4 v-if="currentPasswordError" class="error-message">{{currentPasswordError}}</h4> </div> @@ -84,7 +85,8 @@ const clearInput = () => { <input class="input" :class="{'error': newPasswordError}" type="password" - v-model="newPassword"> + v-model="newPassword" + data-testid="new-password-input"> <div class="alert-box"> <h4 v-if="newPasswordError" class="error-message">{{newPasswordError}}</h4> <h4 v-if="passwordError" class="error-message">{{passwordError}}</h4>