Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dispatch = action => {
if (called++) {
expect(require('isomorphic-fetch').__getRequestedUrl(mockData)).toBe(`http://wordpress.test/wp-json/wp/v2/${endpoint}/${endpoint2}?context=view`);
expect(action.type).toBe(`@@wp/${name}/fetched/${endpoint}/${endpoint2}`);
expect(action.total).toBeUndefined();
expect(action.totalPages).toBeUndefined();
expect(action.results).toBeUndefined();
expect(action.ok).toBeFalsy();
expect(action.message).toBe(statusText);
} else {
expect(action.type).toBe(`@@wp/${name}/fetching/${endpoint}/${endpoint2}`);
}
expect(action.params).toEqual(params);
};
const dispatch = action => {
if (called++) {
expect(require('isomorphic-fetch').__getRequestedUrl(mockData)).toBe(`http://wordpress.test/wp-json/wp/v2/${endpoint}/${item.id}?context=view`);
expect(action.type).toBe(`@@wp/${name}/fetched-by-id/${endpoint}`);
expect(action.ok).toBeTruthy();
expect(action.result).toEqual(item);
} else {
expect(action.type).toBe(`@@wp/${name}/fetching-by-id/${endpoint}`);
}
expect(action.params).toEqual(params);
expect(action.id).toBe(item.id);
};
const dispatch = action => {
if (called++) {
expect(require('isomorphic-fetch').__getRequestedUrl(mockData)).toBe(`http://wordpress.test/wp-json/wp/v2/${endpoint}/${id}/${endpoint2}?context=view`);
expect(action.type).toBe(`@@wp/${name}/fetched-by-id/${endpoint}/${endpoint2}`);
expect(action.result).toBeUndefined();
expect(action.ok).toBeFalsy();
expect(action.message).toBe(statusText);
} else {
expect(action.type).toBe(`@@wp/${name}/fetching-by-id/${endpoint}/${endpoint2}`);
}
expect(action.params).toEqual(params);
expect(action.id).toBe(id);
};
const dispatch = action => {
if (called++) {
expect(require('isomorphic-fetch').__getRequestedUrl(mockData)).toBe(`http://wordpress.test/wp-json/wp/v2/${endpoint}?context=view`);
expect(action.type).toBe(`@@wp/${name}/fetched/${endpoint}`);
expect(action.total).toBeUndefined();
expect(action.totalPages).toBeUndefined();
expect(action.results).toBeUndefined();
expect(action.ok).toBeFalsy();
expect(action.message).toBe(statusText);
} else {
expect(action.type).toBe(`@@wp/${name}/fetching/${endpoint}`);
}
expect(action.params).toEqual(params);
};