2022-01-26 22:10:35 +00:00
|
|
|
const VueTestUtils = require( '@vue/test-utils' );
|
|
|
|
const App = require( '../../resources/skins.vector.search/App.vue' );
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
id: 'searchform',
|
|
|
|
searchAccessKey: 'f',
|
|
|
|
searchTitle: 'search',
|
2023-03-28 18:45:35 +00:00
|
|
|
showThumbnail: true,
|
|
|
|
showDescription: true,
|
|
|
|
highlightQuery: true,
|
2022-01-26 22:10:35 +00:00
|
|
|
searchPlaceholder: 'Search MediaWiki',
|
|
|
|
searchQuery: ''
|
|
|
|
};
|
|
|
|
|
|
|
|
const mount = ( /** @type {Object} */ customProps ) => {
|
|
|
|
return VueTestUtils.shallowMount( App, {
|
2022-02-01 20:52:16 +00:00
|
|
|
props: Object.assign( {}, defaultProps, customProps ),
|
|
|
|
global: {
|
|
|
|
mocks: {
|
|
|
|
$i18n: ( /** @type {string} */ str ) => ( {
|
|
|
|
text: () => str
|
|
|
|
} )
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
'i18n-html': ( el, binding ) => {
|
2024-01-11 19:08:25 +00:00
|
|
|
el.innerHTML = `${ binding.arg } (${ binding.value })`;
|
2022-02-01 20:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-26 22:10:35 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
describe( 'App', () => {
|
|
|
|
it( 'renders a typeahead search component', () => {
|
|
|
|
const wrapper = mount();
|
|
|
|
expect(
|
|
|
|
wrapper.element
|
|
|
|
).toMatchSnapshot();
|
|
|
|
} );
|
|
|
|
} );
|