Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions src/__tests__/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
import Client from "../client";

describe("API Client", function (): void {
test("should be able to make a request using basic auth", async function (): Promise<void> {
new Client({
username: process.env.ADYEN_USER!,
password: process.env.ADYEN_PASSWORD!,
environment: "TEST"
});
test("should be able to make a request using basic auth", async function (): Promise<void> {
new Client({
username: process.env.ADYEN_USER!,
password: process.env.ADYEN_PASSWORD!,
environment: "TEST"
});
});

test("should create client with API key", () => {
const client = new Client({
apiKey: "ADYEN_API_KEY",
environment: "TEST"
});

expect(client.config.apiKey).toBe("ADYEN_API_KEY");
expect(client.config.environment).toBe("TEST");
expect(client.config.marketPayEndpoint).toBe(Client.MARKETPAY_ENDPOINT_TEST);
});

test("should create client with basic auth credentials", () => {
const client = new Client({
username: "username",
password: "password",
environment: "TEST"
});

expect(client.config.username).toBe("username");
expect(client.config.password).toBe("password");
expect(client.config.environment).toBe("TEST");
});

test("should set application name", () => {
const client = new Client({
apiKey: "ADYEN_API_KEY",
environment: "TEST",
applicationName: "my_application_name"
});

expect(client.config.applicationName).toBe("my_application_name");
});

test("should set timeout", () => {
const client = new Client({
apiKey: "ADYEN_API_KEY",
environment: "TEST"
});

client.setTimeouts(30000);
expect(client.config.connectionTimeoutMillis).toBe(30000);
});
});
7 changes: 4 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ class Client {
if (options.username && options.password) {
this.config.username = options.username;
this.config.password = options.password;
if(options.applicationName) {
this.config.applicationName = options.applicationName;
}
}

if (options.apiKey) {
this.config.apiKey = options.apiKey;
}
}

if(options.applicationName) {
this.config.applicationName = options.applicationName;
}

if (options.httpClient) {
this._httpClient = options.httpClient;
}
Expand Down