correct load of categorypage on tag click

improved failing tests
This commit is contained in:
2020-06-24 21:47:22 +02:00
parent e640b36ce4
commit 753ea99693
8 changed files with 64 additions and 116 deletions

View File

@ -78,14 +78,7 @@ describe('<TagPreview/>', function () {
});
it('click event triggered', done => {
const mockSuccessResponse = {};
const mockJsonPromise = Promise.resolve(mockSuccessResponse);
const mockFetchPromise = Promise.resolve({
json: () => mockJsonPromise,
});
global.fetch = jest.fn().mockImplementation(() => mockFetchPromise);
it('click event triggered', function () {
const func = jest.fn();
const wrapper = shallow(<TagPreview/>);
@ -96,19 +89,11 @@ describe('<TagPreview/>', function () {
});
// first call of fetch is getting of available tags
expect(global.fetch).toHaveBeenCalledTimes(0);
expect(func).toHaveBeenCalledTimes(0);
wrapper.find('.videopreview').simulate('click');
// now called 1 times
expect(global.fetch).toHaveBeenCalledTimes(1);
process.nextTick(() => {
//callback to close window should have called
expect(func).toHaveBeenCalledTimes(1);
global.fetch.mockClear();
done();
});
expect(func).toHaveBeenCalledTimes(1);
});
});