Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ describe('BackupAndSync - Syncing - Group', () => {
async (
options: Parameters<typeof metadataExports.compareAndSyncMetadata>[0],
) => {
/* eslint-disable jest/no-conditional-in-test */
if (
options.userStorageMetadata &&
'value' in options.userStorageMetadata &&
Expand All @@ -249,7 +248,6 @@ describe('BackupAndSync - Syncing - Group', () => {
applyNameUpdate = options.applyLocalUpdate;
}
return false;
/* eslint-enable jest/no-conditional-in-test */
},
);

Expand All @@ -265,7 +263,6 @@ describe('BackupAndSync - Syncing - Group', () => {

expect(validateNameFunction).toBeDefined();
expect(applyNameUpdate).toBeDefined();
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-conditional-expect */
if (validateNameFunction) {
expect(validateNameFunction('New Name')).toBe(true);
Expand All @@ -281,7 +278,6 @@ describe('BackupAndSync - Syncing - Group', () => {
true,
);
}
/* eslint-enable jest/no-conditional-in-test */
/* eslint-enable jest/no-conditional-expect */
});

Expand All @@ -305,7 +301,6 @@ describe('BackupAndSync - Syncing - Group', () => {
async (
options: Parameters<typeof metadataExports.compareAndSyncMetadata>[0],
) => {
/* eslint-disable jest/no-conditional-in-test */
if (
options.userStorageMetadata &&
'value' in options.userStorageMetadata &&
Expand All @@ -315,7 +310,6 @@ describe('BackupAndSync - Syncing - Group', () => {
applyPinnedUpdate = options.applyLocalUpdate;
}
return false;
/* eslint-enable jest/no-conditional-in-test */
},
);

Expand All @@ -331,7 +325,6 @@ describe('BackupAndSync - Syncing - Group', () => {

expect(validatePinnedFunction).toBeDefined();
expect(applyPinnedUpdate).toBeDefined();
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-conditional-expect */
if (validatePinnedFunction) {
expect(validatePinnedFunction(true)).toBe(true);
Expand All @@ -346,7 +339,6 @@ describe('BackupAndSync - Syncing - Group', () => {
mockContext.controller.setAccountGroupPinned,
).toHaveBeenCalledWith(mockLocalGroup.id, true);
}
/* eslint-enable jest/no-conditional-in-test */
/* eslint-enable jest/no-conditional-expect */
});

Expand All @@ -370,7 +362,6 @@ describe('BackupAndSync - Syncing - Group', () => {
async (
options: Parameters<typeof metadataExports.compareAndSyncMetadata>[0],
) => {
/* eslint-disable jest/no-conditional-in-test */
if (
options.userStorageMetadata &&
'value' in options.userStorageMetadata &&
Expand All @@ -380,7 +371,6 @@ describe('BackupAndSync - Syncing - Group', () => {
applyHiddenUpdate = options.applyLocalUpdate;
}
return false;
/* eslint-enable jest/no-conditional-in-test */
},
);

Expand All @@ -396,7 +386,6 @@ describe('BackupAndSync - Syncing - Group', () => {

expect(validateHiddenFunction).toBeDefined();
expect(applyHiddenUpdate).toBeDefined();
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-conditional-expect */
if (validateHiddenFunction) {
expect(validateHiddenFunction(true)).toBe(true);
Expand All @@ -411,7 +400,6 @@ describe('BackupAndSync - Syncing - Group', () => {
mockContext.controller.setAccountGroupHidden,
).toHaveBeenCalledWith(mockLocalGroup.id, false);
}
/* eslint-enable jest/no-conditional-in-test */
/* eslint-enable jest/no-conditional-expect */
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ describe('BackupAndSync - Syncing - Wallet', () => {
);

expect(applyLocalUpdate).toBeDefined();
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-conditional-expect */
if (applyLocalUpdate) {
await applyLocalUpdate('New Name');
expect(
mockContext.controller.setAccountWalletName,
).toHaveBeenCalledWith(mockLocalWallet.id, 'New Name');
}
/* eslint-enable jest/no-conditional-in-test */
/* eslint-enable jest/no-conditional-expect */
});

Expand Down Expand Up @@ -169,15 +167,13 @@ describe('BackupAndSync - Syncing - Wallet', () => {
);

expect(validateUserStorageValue).toBeDefined();
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-conditional-expect */
if (validateUserStorageValue) {
expect(validateUserStorageValue('valid string')).toBe(true);
expect(validateUserStorageValue(123)).toBe(false);
expect(validateUserStorageValue(null)).toBe(false);
expect(validateUserStorageValue(undefined)).toBe(false);
}
/* eslint-enable jest/no-conditional-in-test */
/* eslint-enable jest/no-conditional-expect */
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ describe('BackupAndSync - UserStorage - Validation', () => {
try {
assertValidLegacyUserStorageAccount(multipleFailuresData);
} catch (error) {
// eslint-disable-next-line jest/no-conditional-in-test
errorMessage = error instanceof Error ? error.message : String(error);
}

Expand Down
2 changes: 0 additions & 2 deletions packages/assets-controllers/src/NftController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3348,7 +3348,6 @@ describe('NftController', () => {

const { nftController } = setupController({
getERC721TokenURI: jest.fn().mockImplementation((tokenAddress) => {
// eslint-disable-next-line jest/no-conditional-in-test
switch (tokenAddress) {
case '0x01':
return 'https://testtokenuri-1.com';
Expand All @@ -3359,7 +3358,6 @@ describe('NftController', () => {
}
}),
getERC1155TokenURI: jest.fn().mockImplementation((tokenAddress) => {
// eslint-disable-next-line jest/no-conditional-in-test
switch (tokenAddress) {
case '0x03':
return 'https://testtokenuri-3.com';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ describe('TokenSearchDiscoveryDataController', () => {
return {
[tokenAddress as Hex]: {
...basePrice,
// eslint-disable-next-line jest/no-conditional-in-test
price: currency === 'USD' ? 10.5 : 9.5,
currency,
},
Expand Down Expand Up @@ -740,7 +739,6 @@ describe('TokenSearchDiscoveryDataController', () => {
const mockFetchTokenPrices = jest
.fn()
.mockImplementation(({ currency }: { currency: string }) => {
// eslint-disable-next-line jest/no-conditional-in-test
if (currency === 'USD') {
return Promise.resolve({ [tokenAddress as Hex]: mockTokenPrice });
}
Expand Down Expand Up @@ -783,14 +781,12 @@ describe('TokenSearchDiscoveryDataController', () => {

(fetchTokenMetadata as jest.Mock).mockImplementation(
(_chainId, address) => {
// eslint-disable-next-line jest/no-conditional-in-test
if (address === tokenAddress1) {
return Promise.resolve({
decimals: 18,
symbol: 'DAI',
name: 'Dai Stablecoin',
});
// eslint-disable-next-line jest/no-conditional-in-test
} else if (address === tokenAddress2) {
return Promise.resolve({
decimals: 6,
Expand Down
1 change: 0 additions & 1 deletion packages/bridge-controller/src/bridge-controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable jest/no-restricted-matchers */
/* eslint-disable jest/no-conditional-in-test */
import { Contract } from '@ethersproject/contracts';
import { deriveStateFromMetadata } from '@metamask/base-controller';
import {
Expand Down
1 change: 0 additions & 1 deletion packages/bridge-controller/src/utils/balance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { fetchTokenBalance } from './balance';
import { FakeProvider } from '../../../../tests/fake-provider';

declare global {
// eslint-disable-next-line no-var
var ethereumProvider: Provider;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-conditional-in-test */
/* eslint-disable jest/no-restricted-matchers */
import { deriveStateFromMetadata } from '@metamask/base-controller';
import type {
Expand Down
10 changes: 0 additions & 10 deletions packages/chain-agnostic-permission/src/scope/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ describe('filter', () => {

it('returns supported and unsupported scopes', () => {
MockAssert.assertScopeSupported.mockImplementation((scopeString) => {
// This is okay; we are inside of a mock.
// eslint-disable-next-line jest/no-conditional-in-test
if (scopeString === 'eip155:1') {
throw new Error('scope not supported');
}
Expand Down Expand Up @@ -174,13 +172,9 @@ describe('filter', () => {
it('returns only supported methods', () => {
MockSupported.isSupportedMethod.mockImplementation(
(scopeString, method) => {
// This is okay; we are inside of a mock.
// eslint-disable-next-line jest/no-conditional-in-test
if (scopeString === 'eip155:1' && method === 'method1') {
return false;
}
// This is okay; we are inside of a mock.
// eslint-disable-next-line jest/no-conditional-in-test
if (scopeString === 'eip155:5' && method === 'methodB') {
return false;
}
Expand Down Expand Up @@ -261,13 +255,9 @@ describe('filter', () => {
it('returns only supported notifications', () => {
MockSupported.isSupportedNotification.mockImplementation(
(scopeString, notification) => {
// This is okay; we are inside of a mock.
// eslint-disable-next-line jest/no-conditional-in-test
if (scopeString === 'eip155:1' && notification === 'notification1') {
return false;
}
// This is okay; we are inside of a mock.
// eslint-disable-next-line jest/no-conditional-in-test
if (scopeString === 'eip155:5' && notification === 'notificationB') {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions packages/controller-utils/src/create-service-policy.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// We use conditions exclusively in this file.
/* eslint-disable jest/no-conditional-in-test */

import { handleWhen } from 'cockatiel';
import { useFakeTimers } from 'sinon';
import type { SinonFakeTimers } from 'sinon';
Expand Down
1 change: 0 additions & 1 deletion packages/earn-controller/src/EarnController.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-conditional-in-test */
import { deriveStateFromMetadata } from '@metamask/base-controller';
import { toHex } from '@metamask/controller-utils';
import type { InternalAccount } from '@metamask/keyring-internal-api';
Expand Down
2 changes: 0 additions & 2 deletions packages/eth-json-rpc-middleware/src/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ describe('createFetchMiddleware', () => {
});

const context = new MiddlewareContext<{ origin: string }>(
// eslint-disable-next-line jest/no-conditional-in-test
origin ? { origin } : [],
);
const expectedHeaders =
// eslint-disable-next-line jest/no-conditional-in-test
originHttpHeaderKey && origin ? { [originHttpHeaderKey]: origin } : {};

await engine.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('inflight cache', () => {
createInflightCacheMiddleware(),
async () => {
hitCount += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (hitCount === 1) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ describe.each([
it('forwards the context to the JSON-RPC handler', async () => {
const rpcHandler = createRpcHandler('test', (request, context) => {
// @ts-expect-error - Intentional type abuse.
// eslint-disable-next-line jest/no-conditional-in-test
return context?.assertGet('foo') ?? request.foo;
});
const provider = new InternalProvider({ engine: rpcHandler });
Expand Down Expand Up @@ -327,7 +326,6 @@ describe.each([
// Transform the engine into a server so we can mock the "handle" method.
// The "handle" method should never throw, but we should be resilient to it anyway.
rpcHandler =
// eslint-disable-next-line jest/no-conditional-in-test
'push' in rpcHandler
? JsonRpcEngineV2.create({ middleware: [asV2Middleware(rpcHandler)] })
: rpcHandler;
Expand Down
2 changes: 0 additions & 2 deletions packages/json-rpc-engine/src/JsonRpcEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ describe('JsonRpcEngine', () => {

engine.push(function (request, response, _next, end) {
// Separate handling for the 4th request.
// eslint-disable-next-line jest/no-conditional-in-test
if (request.id === 4) {
delete response.result;
response.error = rpcErrors.internal({ message: 'foobar' });
Expand Down Expand Up @@ -468,7 +467,6 @@ describe('JsonRpcEngine', () => {

engine.push(function (request, response, _next, end) {
// Separate handling for the 4th request.
// eslint-disable-next-line jest/no-conditional-in-test
if (request.id === 4) {
delete response.result;
response.error = rpcErrors.internal({ message: 'foobar' });
Expand Down
3 changes: 0 additions & 3 deletions packages/json-rpc-engine/src/v2/JsonRpcEngineV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ describe('JsonRpcEngineV2', () => {
Json,
Context
> = async ({ context, next, request }) => {
// eslint-disable-next-line jest/no-conditional-in-test
context.set('id', context.get('id') ?? request.id);

inFlight += 1;
Expand Down Expand Up @@ -1221,7 +1220,6 @@ describe('JsonRpcEngineV2', () => {

it('constructs a mixed engine', async () => {
const mixedMiddleware: JsonRpcMiddleware = ({ request }) => {
// eslint-disable-next-line jest/no-conditional-in-test
return isRequest(request) ? null : undefined;
};
const engine = JsonRpcEngineV2.create({
Expand All @@ -1245,7 +1243,6 @@ describe('JsonRpcEngineV2', () => {
const orchestratorEngine = JsonRpcEngineV2.create({
middleware: [
({ request, context }) =>
// eslint-disable-next-line jest/no-conditional-in-test
isRequest(request)
? requestEngine.handle(request, { context })
: notificationEngine.handle(request as JsonRpcNotification, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ describe('RpcServiceChain', () => {
onRetryListener.mock.calls.reduce(
(memo, call) => {
const { endpointUrl } = call[0];
// There is nothing wrong with this.
// eslint-disable-next-line jest/no-conditional-in-test
memo[endpointUrl] = (memo[endpointUrl] ?? 0) + 1;
return memo;
},
Expand Down Expand Up @@ -681,8 +679,6 @@ describe('RpcServiceChain', () => {
onDegradedListener.mock.calls.reduce(
(memo: Record<string, number>, call) => {
const { endpointUrl } = call[0];
// There is nothing wrong with this.
// eslint-disable-next-line jest/no-conditional-in-test
memo[endpointUrl] = (memo[endpointUrl] ?? 0) + 1;
return memo;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// We use conditions exclusively in this file.
/* eslint-disable jest/no-conditional-in-test */

import { HttpError } from '@metamask/controller-utils';
import { errorCodes } from '@metamask/rpc-errors';
import deepFreeze from 'deep-freeze-strict';
Expand Down
3 changes: 0 additions & 3 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// A lot of the tests in this file have conditionals.
/* eslint-disable jest/no-conditional-in-test */

import { deriveStateFromMetadata } from '@metamask/base-controller';
import {
BuiltInNetworkName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export function testsForRpcMethodsThatCheckForBlockHashInResponse(
// Start the block tracker
blockTracker.on('latest', () => {
numberOfBlocks += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (numberOfBlocks === 2) {
resolve();
}
Expand Down Expand Up @@ -327,8 +326,6 @@ export function testsForRpcMethodsThatCheckForBlockHashInResponse(
},
);

// This is not ideal, but we can refactor this later.
// eslint-disable-next-line jest/no-conditional-in-test
if (providerType === NetworkClientType.Infura) {
// This is not ideal, but we can refactor this later.
// eslint-disable-next-line jest/no-conditional-expect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export function testsForRpcMethodSupportingBlockParam(
// Start the block tracker
blockTracker.on('latest', () => {
numberOfBlocks += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (numberOfBlocks === 2) {
resolve();
}
Expand Down Expand Up @@ -404,8 +403,6 @@ export function testsForRpcMethodSupportingBlockParam(
},
);

// This is not ideal, but we can refactor this later.
// eslint-disable-next-line jest/no-conditional-in-test
if (providerType === NetworkClientType.Infura) {
// This is not ideal, but we can refactor this later.
// eslint-disable-next-line jest/no-conditional-expect
Expand Down
Loading
Loading