-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refs DPLAN-12968): introduce condensed search field [vue 3] (1156)
* feat(refs DPLAN-12968, #AB21840): introduce condensed search field search button is now an icon-only button that is attached to the right side of the search field * test(refs DPLAN-12968, #AB21840): add unit test * docs(refs DPLAN-12968, #AB21840): add changelog entry * style(refs DPLAN-12968): use demosplan-ui translations * fix(refs DPLAN-12968): remove duplicate button
- Loading branch information
Showing
4 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { afterEach, beforeEach, expect, it } from '@jest/globals' | ||
import DpButton from '~/components/DpButton' | ||
import DpSearchField from '~/components/DpSearchField' | ||
import { mount } from '@vue/test-utils' | ||
|
||
describe('DpSearchField', () => { | ||
let wrapper | ||
const mocks = { | ||
Translator: { | ||
trans: jest.fn((key => key)) | ||
} | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = mount(DpSearchField, { | ||
components: { | ||
DpButton | ||
}, | ||
mocks, | ||
stubs: { | ||
DpResettableInput: true | ||
} | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('emits a search event with the search term when search button is clicked and search term is changed', async() => { | ||
wrapper.setData({ searchTerm: 'test search' }) | ||
await wrapper.find('[data-cy="handleSearch"]').trigger('click') | ||
|
||
expect(wrapper.emitted().search[0]).toEqual(['test search']) | ||
}) | ||
|
||
it('does not emit a search event when search button is clicked and search term is unchanged', async () => { | ||
wrapper.setData({ searchTerm: 'test search' }) | ||
wrapper.setData({ searchTermApplied: 'test search' }) | ||
await wrapper.find('[data-cy="handleSearch"]').trigger('click') | ||
|
||
expect(wrapper.emitted().search).toBeUndefined() | ||
}) | ||
|
||
it('emits a reset event when search field is reset', async() => { | ||
wrapper.setData({ searchTerm: 'test search' }) | ||
wrapper.setData({ searchTermApplied: 'test search' }) | ||
await wrapper.vm.handleReset() | ||
|
||
expect(wrapper.emitted().reset[0]).toBeDefined() | ||
}) | ||
|
||
it('does not emit a reset event when search field is reset but no search term has been entered', async() => { | ||
await wrapper.vm.handleReset() | ||
|
||
expect(wrapper.emitted().reset).toBeUndefined() | ||
}) | ||
}) |