Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('', () => {
expect(true).toBe(true);
const store = createStore(reducer, {
insights: {
definitions: testDefinitions,
searches: [
{
name: 'Google',
url: 'https://www.google.com/search?q=Blood%20Meridian',
},
],
wikis: [
{
recipe: defaultRecipe.wikis[0],
doc: wtf(testWikitext),
},
],
text: 'Blood Meridian',
},
recipe: defaultRecipe,
pub: testPub,
ast: [],
});
const { getAllByText, getByTitle, getByText } = render(
,
);
// Expect insight to have opened definitions
getAllByText('noun');
test('', async () => {
const { getByLabelText, getAllByText, getByText } = render(
,
);
// Validate only main section was rendered
getByText("McCarthy's fifth book", { exact: false });
// in second section:
expect(() =>
getByText('The novel follows an adolescent runaway', { exact: false }),
).toThrow();
// in infobox:
expect(() => getByText('historical novel')).toThrow();
// Validate attribution
let el = getByText('Source: Wikipedia:');
el = el.querySelector('a')!;
expect(el.textContent).toBe(
expect(els[1].tagName).toBe('H1');
// Trigger section change from breadcrumbs to main "Blood Meridian or The Evening Redness in the West"
fireEvent.click(
getByText('Blood Meridian or The Evening Redness in the West'),
);
// Validate we're back to main section
getByText('Source: Wikipedia:');
getByText("McCarthy's fifth book", { exact: false });
getByText('Continue Reading');
getByText('Show Statistics');
// Mock wtf_wikipedia.fetch()
const mockFetch = ((wtf as any).fetch = jest.fn());
mockFetch.mockResolvedValueOnce(wtf(alternateTestWikitext));
// Click "Cormac McCarthy" link
fireEvent.click(getByText('Cormac McCarthy'));
// Validate new article was loaded
expect(mockFetch).toHaveBeenCalledTimes(1);
expect(mockFetch.mock.calls[0][0]).toBe('Cormac_McCarthy');
await waitForDomChange();
getByText('American novelist, playwright, and', { exact: false });
// Click back button to main "Blood Meridian" article
fireEvent.click(getByLabelText('Go back to previous article'));
// Validate we're back to main article
getByText("McCarthy's fifth book", { exact: false });
});
function parseLokalhistorieItem(item, extra) {
var extraData = {};
if (extra && _.has(extra, 'revisions')) {
var wikitext = extra.revisions[0]['*'];
var doc = wtf(wikitext);
extraData.media = _getThumbnails(wikitext).concat(_getImages(doc.images()));
extraData.thumbnail = extraData.media.length > 0
? extraData.media[0].image
: null;
var text = _.chain(doc.sections())
.filter(s => {
return BLACKLIST.indexOf(s.title().toLowerCase()) === -1;
}).map(s => `${s.title()}\n${s.plaintext()}`)
.value()
.join('\n\n');
extraData.text = text;
}
var link = `${urlBase}?curid=${item.pageid}`;