diff --git a/.circleci/config.yml b/.circleci/config.yml index 6455cf4..bd4373a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codecov: codecov/codecov@5.0.3 + codecov: codecov/codecov@5.4.3 executors: default: @@ -26,10 +26,17 @@ jobs: - run: name: Run unit tests with coverage command: npm run test:CI + - run: + name: Install Codecov CLI + command: | + sudo apt-get update + sudo apt-get install -y python3-pip + python3 -m pip install --user codecov-cli - codecov/upload: token: CODECOV_TOKEN slug: trolley/javascript-sdk files: coverage/lcov.info + binary: /home/circleci/.local/bin/codecov when: always build: diff --git a/lib/Client.ts b/lib/Client.ts index 638e21b..5a77ae2 100644 --- a/lib/Client.ts +++ b/lib/Client.ts @@ -10,7 +10,7 @@ import ValidationError = Errors.ValidationError; * @hidden */ -const CURRENT_CLIENT_VERSION = "1.1.0"; +const CURRENT_CLIENT_VERSION = require("../package.json").version; const DEFAULT_HEADERS = { "Content-Type": "application/json", "Trolley-Source": `javascript-sdk_${CURRENT_CLIENT_VERSION}`, diff --git a/test/unit/releasePrepSpec.ts b/test/unit/releasePrepSpec.ts index c8dde71..475bf2d 100644 --- a/test/unit/releasePrepSpec.ts +++ b/test/unit/releasePrepSpec.ts @@ -1,11 +1,15 @@ import { Batch, Balance, Configuration, Gateway, OfflinePayment, Payment, Recipient, RecipientAccount } from "../../lib"; import { BalancesGateway } from "../../lib/BalancesGateway"; +import { Client } from "../../lib/Client"; import { PaymentGateway } from "../../lib/PaymentGateway"; import { VerificationGateway } from "../../lib/VerificationGateway"; import * as assert from "assert"; +import * as nock from "nock"; import * as sinon from "sinon"; +const packageInfo = require("../../package.json"); + describe("Release prep endpoint coverage", () => { let sandbox: sinon.SinonSandbox; let client: { @@ -30,6 +34,21 @@ describe("Release prep endpoint coverage", () => { afterEach(() => { sandbox.restore(); + nock.cleanAll(); + }); + + it("uses the package version in the source header", async () => { + const sourceHeader = `javascript-sdk_${packageInfo.version}`; + const request = nock("https://api.trolley.com") + .matchHeader("Trolley-Source", sourceHeader) + .get("/v1/balances") + .reply(200, { ok: true }); + + const apiClient = new Client(new Configuration({ key: "access", secret: "secret" })); + + await apiClient.get("/v1/balances"); + + assert.ok(request.isDone()); }); it("uses documented balance endpoints", async () => {