Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Remove unused PhotoTags component (#872)
Zack Krida4af08e06fb12
diff --git a/src/components/PhotoTags.vue b/src/components/PhotoTags.vuedeleted file mode 100644index 6c2342e8e..000000000--- a/src/components/PhotoTags.vue+++ /dev/null@@ -1,47 +0,0 @@-<template>- <div v-if="tags && tags.length" class="photo_tags">- <h3 v-if="showHeader" class="b-header">- {{ $t('photo-details.information.tags') }}- </h3>- <div class="mt-4">- <template v-for="(tag, index) in getValidTags()">- <button- :key="index"- class="button tag m-1"- @click="searchByTagName(tag.name)"- @keyup.enter="searchByTagName(tag.name)"- >- {{ tag.name }}- </button>- </template>- </div>- </div>-</template>--<script>-import { UPDATE_QUERY } from '~/constants/action-types'-import { SEARCH } from '~/constants/store-modules'-import { mapActions } from 'vuex'--export default {- name: 'PhotoTags',- props: ['tags', 'showHeader'],- computed: {- hasClarifaiTags() {- return this.$props.tags.some((tag) => tag.provider === 'clarifai')- },- },- methods: {- ...mapActions(SEARCH, { setSearchTerm: UPDATE_QUERY }),- isClarifaiTag(provider) {- return provider === 'clarifai'- },- searchByTagName(query) {- this.setSearchTerm({ q: query })- },- getValidTags() {- return this.$props.tags.filter((tag) => !!tag.name)- },- },-}-</script>diff --git a/test/unit/specs/components/photo-tags.spec.js b/test/unit/specs/components/photo-tags.spec.jsdeleted file mode 100644index c92dd0958..000000000--- a/test/unit/specs/components/photo-tags.spec.js+++ /dev/null@@ -1,66 +0,0 @@-import Vuex from 'vuex'-import render from '../../test-utils/render'-import { createLocalVue } from '@vue/test-utils'-import PhotoTags from '~/components/PhotoTags'-import { UPDATE_QUERY } from '~/constants/action-types'--describe('PhotoTags', () => {- let options = null- let props = null-- beforeEach(() => {- props = {- tags: [- {- accuracy: 1,- name: 'foo',- provider: 'clarifai',- },- {- accuracy: 1,- name: 'bar',- provider: 'foo',- },- ],- }-- options = {- propsData: props,- }- })-- it('should render correct contents when tags array is not empty', () => {- const wrapper = render(PhotoTags, options)- expect(wrapper.find('.photo_tags').element).toBeDefined()- expect(wrapper.findAll('.tag').length).toBe(2)- })-- it('should render nothing when tags array is empty', () => {- options.propsData.tags = []- const wrapper = render(PhotoTags, options)- expect(wrapper.find('.photo_tags').element).toBeUndefined()- })-- it('dispatches an action when a tag is clicked', () => {- const dispatchMock = jest.fn()- const localVue = createLocalVue()- localVue.use(Vuex)- const storeMock = new Vuex.Store({- modules: {- search: { namespaced: true, actions: { [UPDATE_QUERY]: dispatchMock } },- },- })- const opts = {- localVue,- propsData: {- ...props,- },- store: storeMock,- }- const wrapper = render(PhotoTags, opts)- wrapper.find('.tag').trigger('click')- const tagName = wrapper.find('.tag').text()- const dispatchArgs = dispatchMock.mock.calls[0][1]- expect(dispatchArgs).toEqual({ q: tagName })- })-})