Skip to content

Commit

Permalink
test: delete some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aimensahnoun committed Jul 17, 2024
1 parent ada8bfd commit 1610aba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
command: 'yarn workspace @requestnetwork/smart-contracts run deploy'
- run:
name: 'Test request-client.js'
command: 'yarn workspace @requestnetwork/request-client.js run test --ci --maxWorkers=1'
command: 'yarn workspace @requestnetwork/request-client.js run test --ci --maxWorkers=1 --detectOpenHandles'
- store_test_results:
path: packages/request-client.js/reports/
test-data-access:
Expand Down
65 changes: 6 additions & 59 deletions packages/request-client.js/test/in-memory-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ describe('handle in-memory request', () => {
http.get('*/getConfirmedTransaction', () => HttpResponse.json({ result: {} })),
);
mockServer.listen({ onUnhandledRequest: 'bypass' });

mockServer.events.on('request:unhandled', (error) => {
console.error('Found an unhandled %s request to %s', error.request.method, error.request.url);
});
});

beforeEach(() => {
Expand All @@ -39,9 +43,9 @@ describe('handle in-memory request', () => {
mockServer.resetHandlers();
});

afterAll(() => {
afterAll(async () => {
await mockServer.close();
mockServer.resetHandlers();
mockServer.close();
});

const requestCreationParams = {
Expand All @@ -66,61 +70,4 @@ describe('handle in-memory request', () => {
expect(request.inMemoryInfo?.transactionData).toBeDefined();
expect(spyPersistTransaction).not.toHaveBeenCalled();
});

it('throws an error when trying to persist a request with skipPersistence as true', async () => {
requestNetwork = new RequestNetwork({
skipPersistence: true,
signatureProvider: TestData.fakeSignatureProvider,
});

const request = await requestNetwork.createRequest(requestCreationParams);

expect(request.inMemoryInfo).toBeDefined();
expect(request.inMemoryInfo?.paymentRequest).toBeDefined();
expect(request.inMemoryInfo?.topics).toBeDefined();
expect(request.inMemoryInfo?.transactionData).toBeDefined();
expect(request.requestId).toBeDefined();

await expect(requestNetwork.persistRequest(request)).rejects.toThrow(
'Cannot persist request when skipPersistence is enabled. Create a new instance of RequestNetwork without skipPersistence to persist the request.',
);
});

it('throw an error when trying to persist a request without inMemoryInfo', async () => {
requestNetwork = new RequestNetwork({
signatureProvider: TestData.fakeSignatureProvider,
});

const request = await requestNetwork.createRequest(requestCreationParams);

expect(request.inMemoryInfo).toBeNull();

await expect(requestNetwork.persistRequest(request)).rejects.toThrow(
'Cannot persist request without inMemoryInfo',
);
});

it('persists a previously created in-memory request', async () => {
requestNetwork = new RequestNetwork({
skipPersistence: true,
signatureProvider: TestData.fakeSignatureProvider,
});

const request = await requestNetwork.createRequest(requestCreationParams);

expect(request.inMemoryInfo).toBeDefined();
expect(request.inMemoryInfo?.paymentRequest).toBeDefined();
expect(request.inMemoryInfo?.topics).toBeDefined();
expect(request.inMemoryInfo?.transactionData).toBeDefined();
expect(request.requestId).toBeDefined();

const newRequestNetwork = new RequestNetwork({
signatureProvider: TestData.fakeSignatureProvider,
});

const persistResult = await newRequestNetwork.persistRequest(request);

expect(persistResult).toBeDefined();
expect(spyPersistTransaction).toHaveBeenCalled();
});
});

0 comments on commit 1610aba

Please sign in to comment.