From 38cba13f2ceb665ea9abebb9097be1d6dc7f4837 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 12 Jun 2023 08:41:00 +0200 Subject: [PATCH] fix test coverage --- .../components/Inputs/InputUsername.spec.js | 41 +++++ .../src/components/Inputs/InputUsername.vue | 81 +++++----- frontend/src/components/Menu/Sidebar.spec.js | 4 +- frontend/src/components/Menu/Sidebar.vue | 10 +- .../components/UserSettings/UserName.spec.js | 83 +++++------ .../src/components/UserSettings/UserName.vue | 68 ++++----- .../UserSettings/UserNewsletter.spec.js | 8 +- .../UserSettings/UserNewsletter.vue | 35 ++--- frontend/src/locales/de.json | 9 +- frontend/src/locales/en.json | 9 +- frontend/src/pages/Settings.spec.js | 140 ++++++++++-------- frontend/src/pages/Settings.vue | 113 +++++++------- 12 files changed, 331 insertions(+), 270 deletions(-) create mode 100644 frontend/src/components/Inputs/InputUsername.spec.js diff --git a/frontend/src/components/Inputs/InputUsername.spec.js b/frontend/src/components/Inputs/InputUsername.spec.js new file mode 100644 index 000000000..341d2f391 --- /dev/null +++ b/frontend/src/components/Inputs/InputUsername.spec.js @@ -0,0 +1,41 @@ +import { mount } from '@vue/test-utils' +import InputUsername from './InputUsername' + +const localVue = global.localVue + +describe('UserName Form', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + $store: { + state: { + username: '', + }, + }, + } + + const Wrapper = () => { + return mount(InputUsername, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + it('renders the component', () => { + expect(wrapper.find('div.input-username').exists()).toBeTruthy() + }) + + describe('currentValue', () => { + beforeEach(async () => { + wrapper = Wrapper() + await wrapper.setProps({ value: 'petra' }) + wrapper.vm.currentValue = 'petra swastiska' + }) + it('emits input event with the current value', () => { + expect(wrapper.emitted('input')).toEqual([['petra swastiska']]) + }) + }) + }) +}) diff --git a/frontend/src/components/Inputs/InputUsername.vue b/frontend/src/components/Inputs/InputUsername.vue index e2048a781..77f4722f5 100644 --- a/frontend/src/components/Inputs/InputUsername.vue +++ b/frontend/src/components/Inputs/InputUsername.vue @@ -1,42 +1,57 @@