Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('Filters out verified contracts', async () => {
const logger = {
log: jest.fn()
};
const verifiedResp = JSON.stringify({ status: '1' });
const unverifiedResp = JSON.stringify({ status: '0' });
fetch
.mockReturnValueOnce(new Response(verifiedResp))
.mockReturnValueOnce(new Response(verifiedResp))
.mockImplementation(() => new Response(unverifiedResp));
logger.log
.mockReturnValueOnce(new Response(verifiedResp))
.mockReturnValueOnce(new Response(verifiedResp))
.mockImplementation(() => new Response(unverifiedResp));
const { unverified: unverifiedContracts, alreadyVerified } = await filterOutVerified(
artifactsData,
{ apiUrl, logger }
);
expect(fetch.mock.calls).toMatchSnapshot('Fetch calls');
const fetchReturns = fetch.mock.results.map(({ value: response }) => JSON.parse(response.body));
describe('fetchDevelopers()', () => {
fetch.mockReturnValueOnce({
text: jest.fn().mockReturnValue(mockDevelopers),
});
it('should match snapshot', async () => {
await expect(fetchDevelopers()).resolves.toMatchSnapshot();
});
});
it('should return author website url when it exists', async () => {
const expectedAuthorWebsite = 'https://www.franck-abgrall.me/'
fetch.mockReturnValueOnce(
Promise.resolve({
json: () => Promise.resolve({ blog: expectedAuthorWebsite })
})
)
const githubUsername = 'kefranabg'
const authorWebsite = await getAuthorWebsiteFromGithubAPI(githubUsername)
expect(authorWebsite).toEqual(expectedAuthorWebsite)
})
beforeEach(() => {
fetch
.mockReturnValueOnce(Promise.resolve(new Response(pr960)))
.mockReturnValueOnce(Promise.resolve(JSON.stringify({})))
variables = { url: 'https://github.com/Human-Connection/Human-Connection/pull/960' }
})