Skip to content

Commit 9f39a49

Browse files
committed
PERF-1865: tests
1 parent 17dbf67 commit 9f39a49

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/http_client/base.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ export class ApiRequest {
258258
method: HttpMethod,
259259
body: object | object[] | null,
260260
): Promise<Headers> {
261-
const userAgent =
262-
clientData.userAgent ?? `node-lokalise-api/${await getVersion()}`;
261+
const userAgent = clientData.userAgent?.trim() || `node-lokalise-api/${await getVersion()}`;
263262
const headers = new Headers({
264263
Accept: "application/json",
265264
"User-Agent": userAgent,

test/lokalise/lokalise_api.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ describe("LokaliseApi", () => {
3030
expect(client.clientData.enableCompression).to.be.false;
3131
expect(client.clientData.version).to.eq("api2");
3232
});
33+
34+
it("is expected to contain custom user-agent", () => {
35+
const client = new LokaliseApi({
36+
apiKey: process.env.API_KEY,
37+
header: "Authorization",
38+
userAgent: "CustomUserAgent/1.0",
39+
});
40+
expect(client.clientData.token).to.eq(process.env.API_KEY);
41+
expect(client.clientData.enableCompression).to.be.false;
42+
expect(client.clientData.version).to.eq("api2");
43+
expect(client.clientData.userAgent).to.eq("CustomUserAgent/1.0");
44+
});
3345
});
3446

3547
describe("LokaliseApi host", () => {

0 commit comments

Comments
 (0)