1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/development/mock-e2e.js
PeterYinusa d1c05195dd
E2e improve mocking (#13841)
* improve mocking

* improve mocking

* Unnecessary await
2022-03-07 19:23:04 +00:00

35 lines
923 B
JavaScript

async function setupMocking(server, testSpecificMock) {
await server.forAnyRequest().thenPassThrough();
await server
.forOptions('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
.thenCallback(() => {
return {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'Access-Control-Allow-Headers': 'content-type,x-client-id',
},
statusCode: 200,
};
});
await server
.forGet('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
.thenCallback(() => {
return {
headers: { 'Access-Control-Allow-Origin': '*' },
statusCode: 200,
json: {
SafeGasPrice: '1',
ProposeGasPrice: '2',
FastGasPrice: '3',
},
};
});
testSpecificMock(server);
}
module.exports = { setupMocking };