Skip to content

Commit 8aeb564

Browse files
Updated tests
1 parent 42ef5c0 commit 8aeb564

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

contentcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogFilters.spec.js

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
22
import { factory } from '../../../store';
33
import router from '../../../router';
44
import CatalogFilters from '../CatalogFilters';
5+
import CatalogFilterPanelContent from '../CatalogFilterPanelContent';
56

67
const store = factory();
78

@@ -24,25 +25,44 @@ describe('catalogFilters', () => {
2425
});
2526

2627
describe('keywords', () => {
27-
it('should call setKeywords when keywords change', () => {
28-
const setKeywordsMock = jest.fn();
29-
const setKeywords = () => {
30-
return () => {
31-
setKeywordsMock();
32-
};
33-
};
34-
wrapper = makeWrapper({ setKeywords });
35-
const keywords = wrapper.find('[data-test="keywords"]');
36-
keywords.element.value = 'test';
37-
keywords.trigger('input');
38-
expect(setKeywordsMock).toHaveBeenCalled();
28+
it('should update keywords data when updateKeywords is called', async () => {
29+
wrapper = mount(CatalogFilterPanelContent, {
30+
sync: false,
31+
router,
32+
store,
33+
});
34+
35+
await wrapper.setData({ keywordInput: 'initial value' });
36+
37+
wrapper.vm.updateKeywords();
38+
39+
expect(wrapper.vm.keywords).toBe('initial value');
40+
});
41+
42+
it('keywordInput should sync with route query parameters on mount', async () => {
43+
const keywords = 'route keywords';
44+
await router.push({ query: { keywords } });
45+
46+
wrapper = mount(CatalogFilterPanelContent, {
47+
sync: false,
48+
router,
49+
store,
50+
});
51+
52+
expect(wrapper.vm.keywordInput).toBe(keywords);
3953
});
40-
it('keywordInput should stay in sync with query param', () => {
41-
const keywords = 'testing new keyword';
42-
router.push({ query: { keywords } });
43-
wrapper.vm.$nextTick(() => {
44-
expect(wrapper.vm.keywordInput).toBe(keywords);
54+
55+
it('keywordInput should update when route query parameters change', async () => {
56+
wrapper = mount(CatalogFilterPanelContent, {
57+
sync: false,
58+
router,
59+
store,
4560
});
61+
62+
const keywords = 'new route keywords';
63+
await router.push({ query: { keywords } });
64+
65+
expect(wrapper.vm.keywordInput).toBe(keywords);
4666
});
4767
});
4868
});

0 commit comments

Comments
 (0)