Skip to content

Commit 13a351d

Browse files
authored
Fix: Set ApplicationName correctly when client is instantiated (#1503)
1 parent 78f079d commit 13a351d

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

src/__tests__/client.spec.ts

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
11
import Client from "../client";
22

33
describe("API Client", function (): void {
4-
test("should be able to make a request using basic auth", async function (): Promise<void> {
5-
new Client({
6-
username: process.env.ADYEN_USER!,
7-
password: process.env.ADYEN_PASSWORD!,
8-
environment: "TEST"
9-
});
4+
test("should be able to make a request using basic auth", async function (): Promise<void> {
5+
new Client({
6+
username: process.env.ADYEN_USER!,
7+
password: process.env.ADYEN_PASSWORD!,
8+
environment: "TEST"
109
});
10+
});
11+
12+
test("should create client with API key", () => {
13+
const client = new Client({
14+
apiKey: "ADYEN_API_KEY",
15+
environment: "TEST"
16+
});
17+
18+
expect(client.config.apiKey).toBe("ADYEN_API_KEY");
19+
expect(client.config.environment).toBe("TEST");
20+
expect(client.config.marketPayEndpoint).toBe(Client.MARKETPAY_ENDPOINT_TEST);
21+
});
22+
23+
test("should create client with basic auth credentials", () => {
24+
const client = new Client({
25+
username: "username",
26+
password: "password",
27+
environment: "TEST"
28+
});
29+
30+
expect(client.config.username).toBe("username");
31+
expect(client.config.password).toBe("password");
32+
expect(client.config.environment).toBe("TEST");
33+
});
34+
35+
test("should set application name", () => {
36+
const client = new Client({
37+
apiKey: "ADYEN_API_KEY",
38+
environment: "TEST",
39+
applicationName: "my_application_name"
40+
});
41+
42+
expect(client.config.applicationName).toBe("my_application_name");
43+
});
44+
45+
test("should set timeout", () => {
46+
const client = new Client({
47+
apiKey: "ADYEN_API_KEY",
48+
environment: "TEST"
49+
});
50+
51+
client.setTimeouts(30000);
52+
expect(client.config.connectionTimeoutMillis).toBe(30000);
53+
});
1154
});

src/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,17 @@ class Client {
5959
if (options.username && options.password) {
6060
this.config.username = options.username;
6161
this.config.password = options.password;
62-
if(options.applicationName) {
63-
this.config.applicationName = options.applicationName;
64-
}
6562
}
6663

6764
if (options.apiKey) {
6865
this.config.apiKey = options.apiKey;
6966
}
7067
}
7168

69+
if(options.applicationName) {
70+
this.config.applicationName = options.applicationName;
71+
}
72+
7273
if (options.httpClient) {
7374
this._httpClient = options.httpClient;
7475
}

0 commit comments

Comments
 (0)