| 1 |
const VueTestUtils = require( '@vue/test-utils' ); |
| 2 |
const App = require( '../../resources/skins.vector.search/App.vue' ); |
| 3 |
|
| 4 |
const defaultProps = { |
| 5 |
id: 'searchform', |
| 6 |
searchAccessKey: 'f', |
| 7 |
searchTitle: 'search', |
| 8 |
showThumbnail: true, |
| 9 |
showDescription: true, |
| 10 |
highlightQuery: true, |
| 11 |
searchPlaceholder: 'Search MediaWiki', |
| 12 |
searchQuery: '' |
| 13 |
}; |
| 14 |
|
| 15 |
const mount = ( customProps ) => VueTestUtils.shallowMount( App, { |
| 16 |
props: Object.assign( {}, defaultProps, customProps ), |
| 17 |
global: { |
| 18 |
mocks: { |
| 19 |
$i18n: ( str ) => ( { |
| 20 |
text: () => str |
| 21 |
} ) |
| 22 |
}, |
| 23 |
directives: { |
| 24 |
'i18n-html': ( el, binding ) => { |
| 25 |
el.innerHTML = `${ binding.arg } (${ binding.value })`; |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
} ); |
| 30 |
|
| 31 |
describe( 'App', () => { |
| 32 |
it( 'renders a typeahead search component', () => { |
| 33 |
const wrapper = mount(); |
| 34 |
expect( |
| 35 |
wrapper.element |
| 36 |
).toMatchSnapshot(); |
| 37 |
} ); |
| 38 |
} ); |