fix: lint and test for SearchableInput ok

This commit is contained in:
ogerly 2020-04-22 09:58:53 +02:00
parent 1d79900e5e
commit 4a60911c9a
5 changed files with 22 additions and 12 deletions

View File

@ -46,6 +46,7 @@ describe('SearchResults', () => {
describe('contains posts', () => { describe('contains posts', () => {
beforeEach(() => { beforeEach(() => {
console.log
wrapper.setData({ posts: [post], activeTab: 'Post' }) wrapper.setData({ posts: [post], activeTab: 'Post' })
}) })

View File

@ -1,14 +1,20 @@
<template> <template>
<div id="search-results" class="search-results"> <div id="search-results" class="search-results">
<div class="search-results"> <div>
{{ $t('search.results', { searchCount: searchCount, search: search }) }} <ds-section>
<ds-text class="search-results">
<strong>{{ searchCount }}</strong>
{{ $t('search.results') }}
</ds-text>
</ds-section>
</div> </div>
<tab-navigation :tabs="tabOptions" :activeTab="activeTab" @switchTab="switchTab" /> <tab-navigation :tabs="tabOptions" :activeTab="activeTab" @switchTab="switchTab" />
<section <section
:class="['results', activeTab === 'User' && '--user', !activeResourceCount > 0 && '--empty']" :class="['results', activeTab === 'User' && '--user', !activeResourceCount > 0 && '--empty']"
> >
<hc-empty <hc-empty
v-if="!activeResourceCount" v-if="!activeResourceCount || searchCount === 0"
icon="tasks" icon="tasks"
:message="$t('search.no-results', { search })" :message="$t('search.no-results', { search })"
/> />

View File

@ -60,13 +60,6 @@ describe('SearchableInput.vue', () => {
expect(select.element.value).toBe('abcd') expect(select.element.value).toBe('abcd')
}) })
it('searches for the term when enter is pressed', async () => {
select.element.value = 'ab'
select.trigger('input')
select.trigger('keyup.enter')
await expect(wrapper.emitted().query[0]).toEqual(['ab'])
})
it('calls onDelete when the delete key is pressed', () => { it('calls onDelete when the delete key is pressed', () => {
const spy = jest.spyOn(wrapper.vm, 'onDelete') const spy = jest.spyOn(wrapper.vm, 'onDelete')
select.trigger('input') select.trigger('input')
@ -117,5 +110,15 @@ describe('SearchableInput.vue', () => {
expect(mocks.$router.push).toHaveBeenCalledWith('?hashtag=Hashtag') expect(mocks.$router.push).toHaveBeenCalledWith('?hashtag=Hashtag')
}) })
}) })
it('searches for the term when enter is pressed', async () => {
select.element.value = 'ab'
select.trigger('input')
select.trigger('keyup.enter')
expect(mocks.$router.push).toHaveBeenCalledWith({
path: '/search/search-results',
query: { search: 'ab' },
})
})
}) })
}) })

View File

@ -595,7 +595,7 @@
"User": "Benutzer" "User": "Benutzer"
}, },
"hint": "Wonach suchst Du?", "hint": "Wonach suchst Du?",
"results": " \"{searchCount}\" Ergebnisse für \"{search}\" gefunden ", "results": "Ergebnisse gefunden ",
"no-results": "Keine Ergebnisse für \"{search}\" gefunden. Versuch' es mit einem anderen Begriff!", "no-results": "Keine Ergebnisse für \"{search}\" gefunden. Versuch' es mit einem anderen Begriff!",
"placeholder": "Suchen" "placeholder": "Suchen"
}, },

View File

@ -595,7 +595,7 @@
"User": "Users" "User": "Users"
}, },
"hint": "What are you searching for?", "hint": "What are you searching for?",
"results": " \"{searchCount}\" Results found for \"{search}\" ", "results": "{searchCount} Results founding",
"no-results": "No results found for \"{search}\". Try a different search term!", "no-results": "No results found for \"{search}\". Try a different search term!",
"placeholder": "Search" "placeholder": "Search"
}, },