Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyoboieltr committed Jun 14, 2024
1 parent 2297c79 commit 0c5d23f
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions app/scripts/controllers/swaps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,14 +563,12 @@ describe('SwapsController', function () {
.mockReturnValue(getMockQuotes());

// Make it so approval is not required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

const [newQuotes] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
Expand Down Expand Up @@ -634,14 +632,12 @@ describe('SwapsController', function () {
.mockReturnValue(getMockQuotes());

// Make it so approval is not required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

const [newQuotes] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
Expand Down Expand Up @@ -680,7 +676,7 @@ describe('SwapsController', function () {
});

it('performs the allowance check', async function () {
const fetchTradesInfoSpy = jest
jest
.spyOn(swapsController, '_fetchTradesInfo')
.mockReturnValue(getMockQuotes());

Expand All @@ -690,9 +686,7 @@ describe('SwapsController', function () {
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
Expand All @@ -708,19 +702,17 @@ describe('SwapsController', function () {
});

it('gets the gas limit if approval is required', async function () {
const fetchTradesInfoSpy = jest
jest
.spyOn(swapsController, '_fetchTradesInfo')
.mockReturnValue(MOCK_QUOTES_APPROVAL_REQUIRED);

// Ensure approval is required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(0));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

const timedoutGasReturnResult = { gasLimit: 1000000 };
const timedoutGasReturnSpy = jest
Expand All @@ -741,19 +733,17 @@ describe('SwapsController', function () {
});

it('marks the best quote', async function () {
const fetchTradesInfoSpy = jest
jest
.spyOn(swapsController, '_fetchTradesInfo')
.mockReturnValue(getMockQuotes());

// Make it so approval is not required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
Expand All @@ -779,19 +769,15 @@ describe('SwapsController', function () {
};
const quotes = { ...getMockQuotes(), [bestAggId]: bestQuote };

const fetchTradesInfoSpy = jest
.spyOn(swapsController, '_fetchTradesInfo')
.mockReturnValue(quotes);
jest.spyOn(swapsController, '_fetchTradesInfo').mockReturnValue(quotes);

// Make it so approval is not required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
Expand All @@ -803,19 +789,17 @@ describe('SwapsController', function () {
});

it('does not mark as best quote if no conversion rate exists for destination token', async function () {
const fetchTradesInfoSpy = jest
jest
.spyOn(swapsController, '_fetchTradesInfo')
.mockReturnValue(getMockQuotes());

// Make it so approval is not required
const getERC20AllowanceSpy = jest
jest
.spyOn(swapsController, '_getERC20Allowance')
.mockReturnValue(BigNumber.from(1));

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

swapsController.getTokenRatesState = () => ({
marketData: {
Expand All @@ -839,7 +823,7 @@ describe('SwapsController', function () {
const currentEthersInstance = _swapsController.ethersProvider;

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
jest
.spyOn(_swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();

Expand All @@ -864,9 +848,7 @@ describe('SwapsController', function () {
const currentEthersInstance = _swapsController.ethersProvider;

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
.spyOn(swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();
jest.spyOn(swapsController, '_setSwapsNetworkConfig').mockReturnValue();

await swapsController.fetchAndSetQuotes(MOCK_FETCH_PARAMS, {
...MOCK_FETCH_METADATA,
Expand All @@ -893,7 +875,7 @@ describe('SwapsController', function () {
_swapsController._ethersProviderChainId;

// Make the network fetch error message disappear
const setSwapsNetworkConfigSpy = jest
jest
.spyOn(_swapsController, '_setSwapsNetworkConfig')
.mockReturnValue();

Expand Down

0 comments on commit 0c5d23f

Please sign in to comment.