diff --git a/webapp/components/LocationInfo/LocationInfo.spec.js b/webapp/components/LocationInfo/LocationInfo.spec.js new file mode 100644 index 000000000..7771da8ce --- /dev/null +++ b/webapp/components/LocationInfo/LocationInfo.spec.js @@ -0,0 +1,45 @@ +import { render } from '@testing-library/vue' +import LocationInfo from './LocationInfo.vue' + +const localVue = global.localVue + +describe('LocationInfo', () => { + const Wrapper = ({ withDistance }) => { + return render(LocationInfo, { + localVue, + propsData: { + locationData: { + name: 'Paris', + distanceToMe: withDistance ? 100 : null, + }, + }, + mocks: { + $t: jest.fn((t) => t), + }, + }) + } + + describe('distance', () => { + it('renders with distance', () => { + const wrapper = Wrapper({ withDistance: true }) + expect(wrapper.container).toMatchSnapshot() + }) + + it('renders without distance', () => { + const wrapper = Wrapper({ withDistance: false }) + expect(wrapper.container).toMatchSnapshot() + }) + }) + + describe('size', () => { + it('renders in base size', () => { + const wrapper = Wrapper({ size: 'base' }) + expect(wrapper.container).toMatchSnapshot() + }) + + it('renders in small size', () => { + const wrapper = Wrapper({ size: 'small' }) + expect(wrapper.container).toMatchSnapshot() + }) + }) +}) diff --git a/webapp/components/UserTeaser/LocationInfo.vue b/webapp/components/LocationInfo/LocationInfo.vue similarity index 51% rename from webapp/components/UserTeaser/LocationInfo.vue rename to webapp/components/LocationInfo/LocationInfo.vue index 67dc46c27..89dbeddf2 100644 --- a/webapp/components/UserTeaser/LocationInfo.vue +++ b/webapp/components/LocationInfo/LocationInfo.vue @@ -1,10 +1,12 @@ @@ -13,12 +15,12 @@ export default { name: 'LocationInfo', props: { locationData: { type: Object, default: null }, - }, - computed: { - distance() { - return this.locationData.distanceToMe === null - ? null - : this.$t('location.distance', { distance: this.locationData.distanceToMe }) + size: { + type: String, + default: 'base', + validator: (value) => { + return value.match(/(small|base)/) + }, }, }, } @@ -36,9 +38,21 @@ export default { align-items: center; justify-content: center; } +} - .distance { +.size-base { + > .distance { margin-top: 8px; } } + +.size-small { + font-size: 0.8rem; + color: #70677e; + margin-bottom: 12px; + + > .distance { + margin-top: 2px; + } +} diff --git a/webapp/components/LocationInfo/__snapshots__/LocationInfo.spec.js.snap b/webapp/components/LocationInfo/__snapshots__/LocationInfo.spec.js.snap new file mode 100644 index 000000000..e8a1e2a44 --- /dev/null +++ b/webapp/components/LocationInfo/__snapshots__/LocationInfo.spec.js.snap @@ -0,0 +1,99 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LocationInfo distance renders with distance 1`] = ` +
+
+
+ + + + + Paris + +
+ +
+ + location.distance + +
+
+
+`; + +exports[`LocationInfo distance renders without distance 1`] = ` +
+
+
+ + + + + Paris + +
+ + +
+
+`; + +exports[`LocationInfo size renders in base size 1`] = ` +
+
+
+ + + + + Paris + +
+ + +
+
+`; + +exports[`LocationInfo size renders in small size 1`] = ` +
+
+
+ + + + + Paris + +
+ + +
+
+`; diff --git a/webapp/components/UserTeaser/LocationInfo.spec.js b/webapp/components/UserTeaser/LocationInfo.spec.js deleted file mode 100644 index 2b100e66d..000000000 --- a/webapp/components/UserTeaser/LocationInfo.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import { render } from '@testing-library/vue' -import LocationInfo from './LocationInfo.vue' - -const localVue = global.localVue - -describe('LocationInfo', () => { - const Wrapper = ({ withDistance }) => { - return render(LocationInfo, { - localVue, - propsData: { - locationData: { - name: 'Paris', - distanceToMe: withDistance ? 100 : null, - }, - }, - mocks: { - $t: jest.fn((t) => t), - }, - }) - } - - it('renders with distance', () => { - const wrapper = Wrapper({ withDistance: true }) - expect(wrapper.container).toMatchSnapshot() - }) - - it('renders without distance', () => { - const wrapper = Wrapper({ withDistance: false }) - expect(wrapper.container).toMatchSnapshot() - }) -}) diff --git a/webapp/components/UserTeaser/UserTeaserPopover.vue b/webapp/components/UserTeaser/UserTeaserPopover.vue index 68fffaf90..e1c553cab 100644 --- a/webapp/components/UserTeaser/UserTeaserPopover.vue +++ b/webapp/components/UserTeaser/UserTeaserPopover.vue @@ -30,7 +30,7 @@