Skip to content

Commit

Permalink
refactor(client): PAYMENTS-2672 Rename vaulting endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldelcore committed May 17, 2018
1 parent 16038ea commit f875f2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export default class Client {
* @param {Function} [callback]
* @return {void}
*/
getShopperInstruments(data, callback) {
this.storeRequestSender.getShopperInstruments(data, callback);
loadInstruments(data, callback) {
this.storeRequestSender.loadInstruments(data, callback);
}

/**
Expand All @@ -125,8 +125,8 @@ export default class Client {
* @param {Function} [callback]
* @return {void}
*/
postTrustedShippingAddress(data, callback) {
this.storeRequestSender.postTrustedShippingAddress(data, callback);
loadInstrumentsWithAddress(data, callback) {
this.storeRequestSender.loadInstrumentsWithAddress(data, callback);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/store/store-request-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class StoreRequestSender {
* @param {Function} [callback]
* @return {void}
*/
getShopperInstruments(data, callback) {
loadInstruments(data, callback) {
const url = this.urlHelper.getInstrumentsUrl(data.storeId, data.shopperId);
const options = {
headers: mapToHeaders(data),
Expand All @@ -57,7 +57,7 @@ export default class StoreRequestSender {
* @param {Function} [callback]
* @return {void}
*/
postTrustedShippingAddress(data, callback) {
loadInstrumentsWithAddress(data, callback) {
const url = this.urlHelper.getTrustedShippingAddressUrl(data.storeId, data.shopperId);
const payload = mapToTrustedShippingAddressPayload(data);
const options = {
Expand Down
16 changes: 8 additions & 8 deletions test/client/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Client', () => {

storeRequestSender = {
getShopperToken: jasmine.createSpy('getShopperToken'),
getShopperInstruments: jasmine.createSpy('getShopperInstruments'),
postTrustedShippingAddress: jasmine.createSpy('postTrustedShippingAddress'),
loadInstruments: jasmine.createSpy('loadInstruments'),
loadInstrumentsWithAddress: jasmine.createSpy('loadInstrumentsWithAddress'),
postShopperInstrument: jasmine.createSpy('postShopperInstrument'),
deleteShopperInstrument: jasmine.createSpy('deleteShopperInstrument'),
};
Expand Down Expand Up @@ -91,22 +91,22 @@ describe('Client', () => {
expect(clientTokenGenerator.generateClientToken).toHaveBeenCalledWith(data, callback);
});

it('request a shopper\'s instruments', () => {
it('load instruments', () => {
const callback = () => {};
const data = storeIntrumentDataMock;

client.getShopperInstruments(data, callback);
client.loadInstruments(data, callback);

expect(storeRequestSender.getShopperInstruments).toHaveBeenCalledWith(data, callback);
expect(storeRequestSender.loadInstruments).toHaveBeenCalledWith(data, callback);
});

it('posts a trusted shipping address', () => {
it('load instruments with shipping address', () => {
const callback = () => {};
const data = trustedShippingAddressDataMock;

client.postTrustedShippingAddress(data, callback);
client.loadInstrumentsWithAddress(data, callback);

expect(storeRequestSender.postTrustedShippingAddress).toHaveBeenCalledWith(data, callback);
expect(storeRequestSender.loadInstrumentsWithAddress).toHaveBeenCalledWith(data, callback);
});

it('posts a new instrument', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/store/store-request-sender.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ describe('StoreRequestSender', () => {
});

it('request a shopper instrument with the appropriately mapped headers', () => {
storeRequestSender.getShopperInstruments(data, () => {});
storeRequestSender.loadInstruments(data, () => {});

expect(urlHelperMock.getInstrumentsUrl).toHaveBeenCalledWith(data.storeId, data.shopperId);
expect(requestSenderMock.sendRequest).toHaveBeenCalled();
expect(mappers.mapToHeaders).toHaveBeenCalled();
});

it('posts a trusted shipping address with the appropriately mapped headers and payload', () => {
storeRequestSender.postTrustedShippingAddress(data, () => {});
storeRequestSender.loadInstrumentsWithAddress(data, () => {});

expect(urlHelperMock.getTrustedShippingAddressUrl).toHaveBeenCalledWith(data.storeId, data.shopperId);
expect(requestSenderMock.postRequest).toHaveBeenCalled();
Expand Down

0 comments on commit f875f2a

Please sign in to comment.