chore: migrate tests to typescript
This commit is contained in:
committed by
Justin Starry
parent
f912c63b22
commit
8ada44456d
40
web3.js/test/agent-manager.test.ts
Normal file
40
web3.js/test/agent-manager.test.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {AgentManager, DESTROY_TIMEOUT_MS} from '../src/agent-manager';
|
||||
import {sleep} from '../src/util/sleep';
|
||||
|
||||
describe('AgentManager', () => {
|
||||
it('works', async () => {
|
||||
const manager = new AgentManager();
|
||||
const agent = manager._agent;
|
||||
expect(manager._activeRequests).to.eq(0);
|
||||
expect(manager._destroyTimeout).to.be.null;
|
||||
|
||||
manager.requestStart();
|
||||
|
||||
expect(manager._activeRequests).to.eq(1);
|
||||
expect(manager._destroyTimeout).to.be.null;
|
||||
|
||||
manager.requestEnd();
|
||||
|
||||
expect(manager._activeRequests).to.eq(0);
|
||||
expect(manager._destroyTimeout).not.to.be.null;
|
||||
|
||||
manager.requestStart();
|
||||
manager.requestStart();
|
||||
|
||||
expect(manager._activeRequests).to.eq(2);
|
||||
expect(manager._destroyTimeout).to.be.null;
|
||||
|
||||
manager.requestEnd();
|
||||
manager.requestEnd();
|
||||
|
||||
expect(manager._activeRequests).to.eq(0);
|
||||
expect(manager._destroyTimeout).not.to.be.null;
|
||||
expect(manager._agent).to.eq(agent);
|
||||
|
||||
await sleep(DESTROY_TIMEOUT_MS);
|
||||
|
||||
expect(manager._agent).not.to.eq(agent);
|
||||
}).timeout(2 * DESTROY_TIMEOUT_MS);
|
||||
});
|
Reference in New Issue
Block a user