* adding more tests - covers article.jsx and elements created from its props and state - added png as static file that needs stubbing * video + channelDetails test coverage * chat + channels tests * channels cc refactor * yarn install * update snapshot and string spacing * chat.jsx test mostly tests rendering elements - does not test imported components, as those are already tested separately - does not imported functions from actions or utils as those will be tested separately as well * cleaning up - mocked response with flush promises for state/component to reflect appropriate changes * snapshot updates
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
global.document.head.innerHTML =
|
|
"<meta name='algolia-public-id' content='abc123' />" +
|
|
"<meta name='algolia-public-key' content='abc123' />" +
|
|
"<meta name='environment' content='test' />";
|
|
|
|
const mockIndex = {
|
|
search: query =>
|
|
new Promise(resolve => {
|
|
process.nextTick(() => {
|
|
const searchResults = {
|
|
ma: {
|
|
hits: [
|
|
{
|
|
name: 'mat',
|
|
path: 'some_path',
|
|
title: 'some_title',
|
|
id: 'some_id',
|
|
},
|
|
],
|
|
nbHits: 1,
|
|
page: 0,
|
|
nbPages: 1,
|
|
hitsPerPage: 10,
|
|
processingTimeMS: 1,
|
|
exhaustiveNbHits: true,
|
|
query: 'ma',
|
|
params:
|
|
'query=ma&hitsPerPage=10&filters=supported%3Atrue&restrictIndices=searchables_development%2CTag_development%2Cordered_articles_development%2Cordered_articles_by_published_at_development%2Cordered_articles_by_positive_reactions_count_development%2Cordered_comments_development',
|
|
},
|
|
};
|
|
|
|
const results = searchResults[query] || { hits: [] };
|
|
|
|
resolve(results);
|
|
});
|
|
}),
|
|
};
|
|
const client = {
|
|
initIndex: index => mockIndex, // eslint-ignore-line
|
|
};
|
|
|
|
export default jest.fn().mockImplementation((id, key) => client); // eslint-ignore-line
|