Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const post = ({url, status, payload, response, name}) => {
if (!requests.length) {
fetch.mockImplementation(fetchMock);
}
const requestId = requests.length;
requests.push({
method: "POST",
url,
payload,
status,
response,
requestId,
calls: []
});
return requestId;
};
beforeEach(async () => {
fetch.mockClear()
fetch.mockImplementation(async (query) => {
if (query.includes(`https://graph.facebook.com/me?access_token=correctAccessToken`)) {
return {
json: () => ({id: 'testFbUserId'})
}
}
if (query.includes(`https://graph.facebook.com/app/?access_token=correctAccessToken`)) {
return {
json: () => ({id: 'MOCKED_FB_APP_ID'})
}
}
if (query.includes(`https://graph.facebook.com/v2.10/`)) {
return {
json: () => ({id: 'testFbUserId', name: 'testUserName', email: 'test@thebrain.pro'})
}
}
return {