Skip to content

Commit

Permalink
Added list user receipt endpoint
Browse files Browse the repository at this point in the history
Modified CHANGELOG
  • Loading branch information
fkrauthan-hyperwallet committed Jul 20, 2016
1 parent 3f65a29 commit 19c1e64
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
0.2.0 (in progress)
-------------------

- Added list program account receipt endpoint
- Added list user receipt endpoint
- Added list prepaid card receipt endpoint

0.1.1 (2016-06-30)
------------------

Expand Down
63 changes: 62 additions & 1 deletion test/Hyperwallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,67 @@ describe("Hyperwallet", () => {
});
});

/** @test {Hyperwallet#listUserReceipts} */
describe("listUserReceipts()", () => {
let client;
let apiClientSpy;

beforeEach(() => {
apiClientSpy = sinon.spy();
client = new Hyperwallet({
username: "test-username",
password: "test-password",
});
client.client = {
doGet: apiClientSpy,
};
});

/** @test {Hyperwallet#listUserReceipts} */
it("should throw error if userToken is missing", () => {
const callback = () => null;
expect(() => client.listUserReceipts(undefined, {}, callback)).to.throw("userToken is required");
});

/** @test {Hyperwallet#listUserReceipts} */
it("should do get call with options", () => {
const callback = () => null;
client.listUserReceipts("test-user-token", { test: "value" }, callback);

apiClientSpy.should.have.been.calledOnce();
apiClientSpy.should.have.been.calledWith("users/test-user-token/receipts", { test: "value" });
});

/** @test {Hyperwallet#listUserReceipts} */
it("should do get call without options", () => {
const callback = () => null;
client.listUserReceipts("test-user-token", {}, callback);

apiClientSpy.should.have.been.calledOnce();
apiClientSpy.should.have.been.calledWith("users/test-user-token/receipts", {});
});

/** @test {Hyperwallet#listUserReceipts} */
it("should handle 204 return", (cb) => {
const callback = (err, data) => {
data.should.be.deep.equal({
count: 0,
data: [],
});

cb();
};
client.listUserReceipts("test-user-token", {}, callback);

apiClientSpy.should.have.been.calledOnce();
apiClientSpy.should.have.been.calledWith("users/test-user-token/receipts", {});

apiClientSpy.getCall(0).args[2](undefined, {}, {
status: 204,
});
});
});

/** @test {Hyperwallet#listPrepaidCardReceipts} */
describe("listPrepaidCardReceipts()", () => {
let client;
Expand Down Expand Up @@ -1634,7 +1695,7 @@ describe("Hyperwallet", () => {
});
});
});

//--------------------------------------
// Internal utils
//--------------------------------------
Expand Down

0 comments on commit 19c1e64

Please sign in to comment.