From f91b7cc5f26dc3b07719dcd4e765ae34e94ca429 Mon Sep 17 00:00:00 2001 From: ingrid <ingrimeg@stud.ntnu.no> Date: Thu, 4 May 2023 04:50:57 +0200 Subject: [PATCH] flere tester --- src/components/EditProfile.vue | 3 -- src/components/__tests__/EditProfile.spec.js | 34 +++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/components/EditProfile.vue b/src/components/EditProfile.vue index 2bba258..8725cfe 100644 --- a/src/components/EditProfile.vue +++ b/src/components/EditProfile.vue @@ -124,13 +124,10 @@ export default { }).catch(error=> { console.log(error) if (error.message === '400') { - if(newRestricted){ - this.alertMsg = '‼ï¸Det oppsto en feil: Sørg for at det finnes mist en standard profil pÃ¥ kontoenâ€¼ï¸ ' } else if(this.updatedProfile.name !== this.initialName || this.updatedProfile.name) { this.alertMsg = '‼ï¸Det oppsto en feil: Det finnes allerede en bruker med samme navn‼ï¸' - } }else{ this.alertMsg = "‼ï¸Det oppsto en feil.‼ï¸" diff --git a/src/components/__tests__/EditProfile.spec.js b/src/components/__tests__/EditProfile.spec.js index ac7c84b..f78db12 100644 --- a/src/components/__tests__/EditProfile.spec.js +++ b/src/components/__tests__/EditProfile.spec.js @@ -20,7 +20,7 @@ describe('EditProfile', () => { const store = useAuthStore(pinia) store.profile = { name:"Ola", - restricted:false, + restricted:true, profileImageUrl:"some/valid/image.png" } @@ -29,4 +29,36 @@ describe('EditProfile', () => { const unameInput = wrapper.find('#brukernavn'); expect(unameInput.element.value).to.contain('Ola'); }) + + it('If profile.restricted is true, then radio input with value false is not selected', () => { + const radioInput = wrapper.find('input[type=radio][value="false"]') + expect(radioInput.element.checked).toBe(false) + }) + + it('If profile.restricted is true, then radio input with valuetrue *is* selected', () => { + const radioInput = wrapper.find('input[type=radio][value="true"]') + expect(radioInput.element.checked).toBe(true) + }) + + //update the value from restricted true -> false + it('After changing restricted radio, the values are updated too', async () => { + const notRestrictedRadioInput = wrapper.find('#normal') + const restrictedRadioInput = wrapper.find('#restricted') + + expect(notRestrictedRadioInput.element.checked).toBe(false) + expect(restrictedRadioInput.element.checked).toBe(true) + + await notRestrictedRadioInput.trigger('click') + + expect(notRestrictedRadioInput.element.checked).toBe(true) + expect(restrictedRadioInput.element.checked).toBe(false) + + await wrapper.vm.$nextTick() + + setTimeout(() => { + expect(wrapper.vm.updatedProfile.upRestricted).toBe(false) + }, 1000); + }) + + }) \ No newline at end of file -- GitLab