Skip to content

Commit 8b6b7a6

Browse files
committed
Added test cases to throttle
1 parent ef2943d commit 8b6b7a6

File tree

4 files changed

+9464
-9439
lines changed

4 files changed

+9464
-9439
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"buildlegacy": "webpack --mode production",
2525
"devlegacy": "webpack --mode development --watch",
2626
"test": "jest --verbose --coverage",
27+
"test-backend": "jest --verbose --coverage src/backend",
2728
"test-on": "./node_modules/.bin/jest $1",
2829
"docker-test-lint": "eslint --ext .js --ext .jsx src",
2930
"docs": "typedoc --json docs --inputFiles src/app --inputFiles src/backend --readme docs/readme.md",

src/backend/__tests__/throttle.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('throttle unit tests', () => {
1414
});
1515

1616
it('should return a function', () => {
17-
const result = throttle(() => {}, 1000);
17+
const result = throttle(mockCallback, 1000);
1818
expect(typeof result).toBe('function');
1919
});
2020

@@ -56,7 +56,9 @@ describe('throttle unit tests', () => {
5656
expect(mockCallback).toHaveBeenCalledTimes(2);
5757

5858
throttledFunc();
59-
jest.advanceTimersByTime(1500);
59+
jest.advanceTimersByTime(100);
60+
throttledFunc();
61+
jest.advanceTimersByTime(901);
6062
expect(mockCallback).toHaveBeenCalledTimes(3);
6163
});
6264
});

src/backend/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'regenerator-runtime/runtime';
1212
import linkFiberInitialization from './routers/linkFiber';
1313
import timeJumpInitialization from './controllers/timeJump';
1414
import { Snapshot, Status, MsgData } from './types/backendTypes';
15-
import componentActionsRecord from './models/masterState';
1615
import routes from './models/routes';
1716

1817
// * State snapshot object initialized here

0 commit comments

Comments
 (0)