Skip to content

Commit 0f4f1a3

Browse files
committed
Dry the tests as per CodeRabbit
1 parent 0e0b7b3 commit 0f4f1a3

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

packages/sdk/src/server/__tests__/server.test.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@ import { ClientCredentials } from "simple-oauth2";
33

44
import {
55
BackendClient,
6+
BackendClientOpts,
67
createBackendClient,
78
HTTPAuthType,
89
} from "../index";
910

11+
const projectId = "proj_abc123";
12+
const clientParams: BackendClientOpts = {
13+
credentials: {
14+
clientId: "test-client-id",
15+
clientSecret: "test-client-secret",
16+
},
17+
projectId,
18+
};
19+
1020
let client: BackendClient;
1121
let customDomainClient: BackendClient;
12-
const projectId = "proj_abc123";
1322

1423
beforeEach(() => {
1524
// @ts-ignore
@@ -23,21 +32,10 @@ beforeEach(() => {
2332
}));
2433

2534
client = new BackendClient(
26-
{
27-
credentials: {
28-
clientId: "test-client-id",
29-
clientSecret: "test-client-secret",
30-
},
31-
projectId,
32-
},
35+
clientParams,
3336
);
34-
3537
customDomainClient = new BackendClient({
36-
credentials: {
37-
clientId: "test-client-id",
38-
clientSecret: "test-client-secret",
39-
},
40-
projectId,
38+
...clientParams,
4139
workflowDomain: "example.com",
4240
});
4341
});
@@ -50,15 +48,7 @@ afterEach(() => {
5048
describe("BackendClient", () => {
5149
describe("createBackendClient", () => {
5250
it("should mock the createBackendClient method and return a BackendClient instance", () => {
53-
const params = {
54-
credentials: {
55-
clientId: "test-client-id",
56-
clientSecret: "test",
57-
},
58-
projectId,
59-
};
60-
61-
client = createBackendClient(params);
51+
const client = createBackendClient(clientParams);
6252
expect(client).toBeInstanceOf(BackendClient);
6353
});
6454
});

0 commit comments

Comments
 (0)