Skip to content

Commit

Permalink
fixed typos in product tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schaechinger committed Mar 26, 2018
1 parent 10b600f commit 8a7b94f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/ProductList/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Client {
* @param {string} [client.id] - The dedicated id of the account if different
* from the username but in caps <MANDANTID>
*/
constructor({ username, password, id = null }) {
constructor({ username, password, id = null } = {}) {
if (!username || !password) {
throw new Error(errors.usage.missingClientCredentials);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/ProductList/Product.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Product {
/** @type {number[]} - The weight range in grams. */
this._weight = [];

this._readData(data);
if (data) {
this._readData(data);
}
}

/**
Expand Down Expand Up @@ -55,7 +57,7 @@ class Product {
return !!this._id;
}

_readData(data) {
_readData(data = {}) {
if (data.hasOwnProperty('extendedIdentifier')) {
this._id = +data.extendedIdentifier.externIdentifier.attributes.id;
this._name = data.extendedIdentifier.externIdentifier.attributes.name;
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
invalidCountryCode: '3002: Invalid country code for address given: ',
missingAddressBindings: '3003: Please add receiver and sender to address binding!',
missingPartnerCredentials: '3004: The api requires valid partner credentials including the id and the secret!',
missingPositionParameters: '3005: A position requires at least the productCode and a voucherLayout!',
missingPositionParameters: '3005: A position requires at least the product or productCode and a voucherLayout!',
invalidLayoutZone: '3006: Invalid voucher layout given: ',
missingProductClients: '3007: The product client credentials are required to make use of the product list. Please add credentials with internetmarke.enableProductList!',
missingClientCredentials: '3008: The api requires valid client credentials including the username and password!'
Expand Down
6 changes: 3 additions & 3 deletions test/Order/Order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe('Order', () => {

const product = {
getId: sinon.stub().returns(1),
getPrice: sinon.stub().returned(70)
getPrice: sinon.stub().returns(70)
};

order.addPosition({ product });
order.addPosition({ product, voucherLayout: 'FrankingZone' });

product.getId.calledOnce.should.be.true();
product.getPrice.calledOnce.should.be.true();

order._positions.length.should.have.length(1);
order._positions.should.have.length(1);
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/ProductList/Client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ describe('Client', () => {
client.getId().should.equal(args.id);
});

it('should generate the client id if not given', () {
it('should generate the client id if not given', () => {
const credentials = {
username: 'myusername',
password: '*****'
};

const client = new Client(credentials);

client.getId().shoul.equal(credentials.username.toUpperCase());
client.getId().should.equal(credentials.username.toUpperCase());
});
});
2 changes: 1 addition & 1 deletion test/ProductList/Product.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Product', () => {
product.getId().should.equal(data.gen.id);
product.getPrice().should.equal(data.gen.price);
product.getName().should.equal(data.gen.name);
product._dimensions.should.have.properties('length', 'weight', 'height');
product._dimensions.should.have.properties('length', 'width', 'height');
product._dimensions.length.should.have.length(2);
product._weight.should.have.length(2);
product._ppl.should.equal(data.gen.ppl);
Expand Down

0 comments on commit 8a7b94f

Please sign in to comment.