2022-07-10 16:13:30 +00:00
|
|
|
import { waitFor } from '@testing-library/vue'
|
2022-05-09 11:12:06 +00:00
|
|
|
import { expect, it } from 'vitest'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-05-09 11:12:06 +00:00
|
|
|
import { searchStore } from '@/stores'
|
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
import SearchExceptsScreen from './SearchExcerptsScreen.vue'
|
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-05-09 11:12:06 +00:00
|
|
|
protected test () {
|
|
|
|
it('executes searching when the search keyword is changed', async () => {
|
|
|
|
const mock = this.mock(searchStore, 'excerptSearch')
|
|
|
|
this.render(SearchExceptsScreen)
|
2022-07-10 16:13:30 +00:00
|
|
|
|
2022-05-09 11:12:06 +00:00
|
|
|
eventBus.emit('SEARCH_KEYWORDS_CHANGED', 'search me')
|
|
|
|
|
2022-07-10 16:13:30 +00:00
|
|
|
await waitFor(() => expect(mock).toHaveBeenCalledWith('search me'))
|
2022-05-09 11:12:06 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|