mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
* feat(webapp): location on registration * add location name to signup verification, allow location query * location name can be prompted in regeistration * default value null for locationName * Prevent ds-select overflow * Remove location name from label * Add margin-bottom to location-select * group location is not affected by REQUIRE_LOCATION, previous location is shown * Update webapp/components/Registration/RegistrationSlideCreate.vue Co-authored-by: Max <maxharz@gmail.com> * Replace more '16px' by '$space-small' and remove class 'password-strength' * Add class 'password-strength' again * property for previous location --------- Co-authored-by: Maximilian Harz <maxharz@gmail.com> Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
100 lines
2.4 KiB
JavaScript
100 lines
2.4 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import LocationSelect from './LocationSelect'
|
|
import { queryLocations } from '~/graphql/location'
|
|
|
|
const localVue = global.localVue
|
|
const propsData = { value: 'nowhere' }
|
|
|
|
let wrapper
|
|
|
|
const queryMock = jest.fn().mockResolvedValue({
|
|
data: {
|
|
queryLocations: [
|
|
{
|
|
place_name: 'Hamburg, Germany',
|
|
place_id: 'xxx',
|
|
},
|
|
],
|
|
},
|
|
})
|
|
|
|
const mocks = {
|
|
$t: jest.fn((string) => string),
|
|
$i18n: {
|
|
locale: () => 'en',
|
|
},
|
|
$apollo: {
|
|
query: queryMock,
|
|
},
|
|
}
|
|
|
|
describe('LocationSelect', () => {
|
|
beforeEach(() => {})
|
|
|
|
describe('mount', () => {
|
|
const Wrapper = () => {
|
|
return mount(LocationSelect, { mocks, localVue, propsData })
|
|
}
|
|
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('renders the label with previous location by default', () => {
|
|
expect(wrapper.find('label.ds-input-label').text()).toBe('settings.data.labelCity — nowhere')
|
|
})
|
|
|
|
it('renders the select', () => {
|
|
expect(wrapper.find('.ds-select').exists()).toBe(true)
|
|
})
|
|
|
|
it('renders the clearLocationName button by default', () => {
|
|
expect(wrapper.find('.base-button').exists()).toBe(true)
|
|
})
|
|
|
|
it('calls apollo with given value', () => {
|
|
expect(queryMock).toBeCalledWith({
|
|
query: queryLocations(),
|
|
variables: {
|
|
place: 'nowhere',
|
|
lang: 'en',
|
|
},
|
|
})
|
|
})
|
|
|
|
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([''])
|
|
})
|
|
})
|
|
|
|
describe('canBeCleared is false', () => {
|
|
beforeEach(() => {
|
|
propsData.canBeCleared = false
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('does not show clear location name button', () => {
|
|
expect(wrapper.find('.base-button').exists()).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('showPreviousLocation is false', () => {
|
|
beforeEach(() => {
|
|
propsData.showPreviousLocation = false
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('does not show the previous location', () => {
|
|
expect(wrapper.find('.ds-input-label').text()).toBe('settings.data.labelCity')
|
|
})
|
|
})
|
|
})
|
|
})
|