Ocelot-Social/webapp/components/Select/LocationSelect.spec.js
mahula 51564e5d9b
refactor(webapp): make group form's location select available as a separate component (#6245)
* WIP make location select a separate component

* trying ...

* fix update of geolocale from component

* clean up location select code

* refactor code

* refactor code

* clean up

* linting

* add first unit tests for location select

* reuse location setting component in user settings

* get it working

* fix unit test

* Update webapp/components/Select/LocationSelect.vue

Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>

* Update webapp/components/Select/LocationSelect.spec.js

Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>

* Update webapp/components/Select/LocationSelect.spec.js

Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>

---------

Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de>
Co-authored-by: ogerly <fridolin@tutanota.com>
Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
2025-05-29 16:58:36 +00:00

53 lines
1.2 KiB
JavaScript

import { mount } from '@vue/test-utils'
import LocationSelect from './LocationSelect'
const localVue = global.localVue
const propsData = { value: 'nowhere' }
let wrapper
const mocks = {
$t: jest.fn((string) => string),
$i18n: {
locale: () => 'en',
},
}
describe('LocationSelect', () => {
beforeEach(() => {})
describe('mount', () => {
const Wrapper = () => {
return mount(LocationSelect, { mocks, localVue, propsData })
}
beforeEach(() => {
wrapper = Wrapper()
})
it('renders the label', () => {
expect(wrapper.find('label.ds-input-label').exists()).toBe(true)
})
it('renders the select', () => {
expect(wrapper.find('.ds-select').exists()).toBe(true)
})
it('renders the clearLocationName button', () => {
expect(wrapper.find('.base-button').exists()).toBe(true)
})
describe('clearLocationName button click', () => {
beforeEach(() => {
wrapper.find('.base-button').trigger('click')
})
it('emits an empty string', () => {
expect(wrapper.emitted().input).toBeTruthy()
expect(wrapper.emitted().input.length).toBe(1)
expect(wrapper.emitted().input[0]).toEqual([''])
})
})
})
})