Skip to content
Draft
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
6 changes: 0 additions & 6 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1439,9 +1439,6 @@
}
},
"packages/phishing-controller/src/PhishingController.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
},
"jest/unbound-method": {
"count": 7
}
Expand Down Expand Up @@ -1483,9 +1480,6 @@
"packages/phishing-controller/src/utils.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 2
},
"import-x/namespace": {
"count": 5
}
},
"packages/phishing-controller/src/utils.ts": {
Expand Down
1 change: 0 additions & 1 deletion packages/app-metadata-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@types/jest": "^27.5.2",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@types/jest": "^27.5.2",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/core-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@types/jest": "^27.5.2",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/phishing-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"nock": "^13.3.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/phishing-controller/src/BulkTokenScan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
MockAnyNamespace,
} from '@metamask/messenger';
import nock, { cleanAll } from 'nock';
import sinon from 'sinon';

import {
PhishingController,
Expand Down Expand Up @@ -118,7 +117,7 @@ describe('PhishingController - Bulk Token Scanning', () => {
});

afterEach(() => {
sinon.restore();
jest.restoreAllMocks();
cleanAll();
consoleErrorSpy.mockRestore();
consoleWarnSpy.mockRestore();
Expand Down
30 changes: 14 additions & 16 deletions packages/phishing-controller/src/CacheManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import sinon from 'sinon';

import { CacheManager } from './CacheManager';
import * as utils from './utils';

describe('CacheManager', () => {
let clock: sinon.SinonFakeTimers;
let updateStateSpy: sinon.SinonSpy;
let updateStateSpy: jest.Mock;
let cache: CacheManager<{ value: string }>;

beforeEach(() => {
clock = sinon.useFakeTimers();
sinon
.stub(utils, 'fetchTimeNow')
.callsFake(() => Math.floor(Date.now() / 1000));
updateStateSpy = sinon.spy();
jest.useFakeTimers();
jest
.spyOn(utils, 'fetchTimeNow')
.mockImplementation(() => Math.floor(Date.now() / 1000));
updateStateSpy = jest.fn();
cache = new CacheManager<{ value: string }>({
cacheTTL: 300, // 5 minutes
maxCacheSize: 3,
Expand All @@ -22,7 +19,8 @@ describe('CacheManager', () => {
});

afterEach(() => {
sinon.restore();
jest.useRealTimers();
jest.restoreAllMocks();
});

describe('constructor', () => {
Expand Down Expand Up @@ -69,7 +67,7 @@ describe('CacheManager', () => {
cache.set('key1', { value: 'value1' });

// Fast forward time past TTL
clock.tick(301 * 1000);
jest.advanceTimersByTime(301 * 1000);

expect(cache.get('key1')).toBeUndefined();
});
Expand All @@ -89,7 +87,7 @@ describe('CacheManager', () => {

it('should call updateState when adding entries', () => {
cache.set('key1', { value: 'value1' });
expect(updateStateSpy.calledOnce).toBe(true);
expect(updateStateSpy).toHaveBeenCalledTimes(1);
});

it('should evict oldest entries when cache exceeds max size', () => {
Expand Down Expand Up @@ -118,9 +116,9 @@ describe('CacheManager', () => {

it('should call updateState when deleting entries', () => {
cache.set('key1', { value: 'value1' });
updateStateSpy.resetHistory();
updateStateSpy.mockClear();
cache.delete('key1');
expect(updateStateSpy.calledOnce).toBe(true);
expect(updateStateSpy).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -135,9 +133,9 @@ describe('CacheManager', () => {

it('should call updateState', () => {
cache.set('key1', { value: 'value1' });
updateStateSpy.resetHistory();
updateStateSpy.mockClear();
cache.clear();
expect(updateStateSpy.calledOnce).toBe(true);
expect(updateStateSpy).toHaveBeenCalledTimes(1);
});
});

Expand Down
Loading
Loading