Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbi08 committed Sep 12, 2024
1 parent b08271e commit cd2ceb1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/transport/test/core/backbone/CorrelationId.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import correlationIdLib from "correlation-id";
import { RequestInterceptor } from "../../testHelpers/RequestInterceptor";
import { TestUtil } from "../../testHelpers/TestUtil";

describe("CorrelationId", function () {
test("should send correlation id to the backend when given", async function () {
// Arrange
const connection = await TestUtil.createDatabaseConnection();
const transport = TestUtil.createTransport(connection);
await transport.init();
const accounts = await TestUtil.provideAccounts(transport, 1);
const testAccount = accounts[0];
const interceptor = new RequestInterceptor((testAccount as any).synchronization.client);

// Act
interceptor.start();
await correlationIdLib.withId("test-correlation-id", async () => {
await testAccount.syncEverything();
});

// Assert
const requests = interceptor.stop().requests;
expect(requests.at(-1)!.headers!["x-correlation-id"]).toBe("test-correlation-id");

// Cleanup
await testAccount.close();
await connection.close();
});
});

0 comments on commit cd2ceb1

Please sign in to comment.