-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/transport/test/core/backbone/CorrelationId.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |