From f04f99c027a0360518ac83dfb0d56186f1f3a8c3 Mon Sep 17 00:00:00 2001 From: henridb <henridb@stud.ntnu.no> Date: Wed, 1 May 2024 14:08:53 +0200 Subject: [PATCH] fix: unit test --- src/components/Login/LoginForm.vue | 6 +++--- src/components/Login/__tests__/LoginForm.spec.ts | 8 ++++---- src/components/SignUp/SignUpForm.vue | 8 ++++---- .../SignUp/__tests__/SignUpForm.spec.ts | 16 ++++++++-------- .../Authentication/ForgottenPasswordView.vue | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/Login/LoginForm.vue b/src/components/Login/LoginForm.vue index ce0cf55..e1d90af 100644 --- a/src/components/Login/LoginForm.vue +++ b/src/components/Login/LoginForm.vue @@ -89,9 +89,9 @@ const handleSubmit = async () => { id="emailInput" input-id="email" type="email" - label="E-postadresse" - placeholder="Skriv inn din e-postadresse" - invalid-message="Ugyldig e-postadresse" + label="E-post" + placeholder="Skriv inn din e-post" + invalid-message="Ugyldig e-post" /> <BaseInput :model-value="passwordRef" diff --git a/src/components/Login/__tests__/LoginForm.spec.ts b/src/components/Login/__tests__/LoginForm.spec.ts index ad99a5c..d97fadf 100644 --- a/src/components/Login/__tests__/LoginForm.spec.ts +++ b/src/components/Login/__tests__/LoginForm.spec.ts @@ -41,8 +41,8 @@ describe('Menu and Router Tests', () => { }, }); - expect(wrapper.text()).toContain('email'); - expect(wrapper.text()).toContain('password'); + expect(wrapper.text()).toContain('E-post'); + expect(wrapper.text()).toContain('Passord'); }); }); @@ -72,8 +72,8 @@ describe('Menu and Router Tests', () => { it('updates user credetials correctly', async () => { const { getByPlaceholderText } = render(MyComponent); - const emailInput = getByPlaceholderText('Enter your email') as HTMLInputElement; - const passwordInput = getByPlaceholderText('Enter password') as HTMLInputElement; + const emailInput = getByPlaceholderText('Skriv inn din e-post') as HTMLInputElement; + const passwordInput = getByPlaceholderText('Skriv inn ditt passord') as HTMLInputElement; await fireEvent.update(emailInput, 'user@example.com'); await fireEvent.update(passwordInput, 'Password1'); diff --git a/src/components/SignUp/SignUpForm.vue b/src/components/SignUp/SignUpForm.vue index f4958b0..6603179 100644 --- a/src/components/SignUp/SignUpForm.vue +++ b/src/components/SignUp/SignUpForm.vue @@ -99,9 +99,9 @@ const handleSubmit = async () => { id="emailInput" input-id="email" type="email" - label="E-postadresse" - placeholder="Skriv inn din e-postadresse" - invalid-message="Ugyldig e-postadresse"/> + label="E-post" + placeholder="Skriv inn din e-post" + invalid-message="Ugyldig e-post"/> </div> <div class="col-sm"> <BaseInput :model-value="passwordRef" @@ -120,7 +120,7 @@ const handleSubmit = async () => { type="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,16}" label="Bekreft Passord" - placeholder="Skriv inn passord" + placeholder="Bekreft passord" invalid-message="Passordet må være mellom 4 og 16 tegn og inneholde én stor bokstav, liten bokstav og et tall" /> </div> diff --git a/src/components/SignUp/__tests__/SignUpForm.spec.ts b/src/components/SignUp/__tests__/SignUpForm.spec.ts index f2a653c..1d66d74 100644 --- a/src/components/SignUp/__tests__/SignUpForm.spec.ts +++ b/src/components/SignUp/__tests__/SignUpForm.spec.ts @@ -39,9 +39,9 @@ describe('Menu and Router Tests', () => { }, }); - expect(wrapper.text()).toContain('First name'); - expect(wrapper.text()).toContain('Surname'); - expect(wrapper.text()).toContain('Email'); + expect(wrapper.text()).toContain('Fornavn'); + expect(wrapper.text()).toContain('Etternavn'); + expect(wrapper.text()).toContain('E-post'); }); }); @@ -71,10 +71,10 @@ describe('Menu and Router Tests', () => { it('updates user credentials correctly', async () => { const { getByPlaceholderText } = render(MyComponent); - const firstInput = getByPlaceholderText('Enter your first name') as HTMLInputElement; - const lastInput = getByPlaceholderText('Enter your surname') as HTMLInputElement; - const emailInput = getByPlaceholderText('Enter your email') as HTMLInputElement; - const passwordInput = getByPlaceholderText('Enter password') as HTMLInputElement; + const firstInput = getByPlaceholderText('Skriv inn ditt fornavn') as HTMLInputElement; + const lastInput = getByPlaceholderText('Skriv inn ditt etternavn') as HTMLInputElement; + const emailInput = getByPlaceholderText('Skriv inn din e-post') as HTMLInputElement; + const passwordInput = getByPlaceholderText('Skriv inn passord') as HTMLInputElement; await fireEvent.update(firstInput, 'Alice'); await fireEvent.update(lastInput, 'Alicon'); @@ -96,7 +96,7 @@ describe('Menu and Router Tests', () => { }); const errorMsg = container.querySelector('#invalid'); // Use the actual ID here - expect(errorMsg?.textContent === "Password must be between 4 and 16 characters and contain one capital letter, small letter and a number") + expect(errorMsg?.textContent === "Passordet må være mellom 4 og 16 tegn og inneholde én stor bokstav, liten bokstav og et tall") }); it('logout should have empty store at application start', () => { diff --git a/src/views/Authentication/ForgottenPasswordView.vue b/src/views/Authentication/ForgottenPasswordView.vue index b518986..acb9def 100644 --- a/src/views/Authentication/ForgottenPasswordView.vue +++ b/src/views/Authentication/ForgottenPasswordView.vue @@ -7,7 +7,7 @@ <div class="form-floating inputBox"> <input v-model="email" class="form-control" id="inputEmail" type="email" placeholder="name@example.com" required> - <label for="emailInput">Enter email address</label> + <label for="emailInput">Skriv inn din e-post</label> </div> <div v-if="errorMessage" class="text-danger"> @@ -19,7 +19,7 @@ <button1 id="confirmButton" type="submit" :disabled="isSubmitting" button-text="Send e-post"></button1> <div class="login-link"> - <Router-Link to="/login" class="small">Return to login</Router-Link> + <Router-Link to="/login" class="small">Gå tilbake</Router-Link> </div> </form> </div> -- GitLab