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 @@