Skip to content
Open
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
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codecov: codecov/codecov@5.0.3
codecov: codecov/codecov@5.4.3

executors:
default:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
19 changes: 19 additions & 0 deletions test/unit/releasePrepSpec.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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 () => {
Expand Down