Skip to content

Commit

Permalink
fix: update user wallet balance if a zero euros
Browse files Browse the repository at this point in the history
  • Loading branch information
schaechinger committed Aug 20, 2021
1 parent da4fa96 commit b35a906
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0] - 2021-08-20

### Added

- Shopping cart matches product with receiver address to avoid wrong vouchers

### Fixed

- User did not set wallet balance if it was empty with zero Euros

## [0.7.1] - 2021-08-20

### Fixed
Expand Down
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Until then only the latest 0.x minor release is supported.

| Version | Supported |
| ------- | ------------------ |
| 0.8.x | :white_check_mark: |
| 0.7.x | :white_check_mark: |
| < 0.7 | :x: |

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "internetmarke",
"version": "0.7.1",
"version": "0.8.0",
"description": "A node implementation to use the Internetmarke web service of Deutsche Post.",
"keywords": [
"internetmarke",
Expand Down Expand Up @@ -31,7 +31,7 @@
"test": "mocha -r ts-node/register 'test/**/*.spec.ts'",
"test:dot": "npm run test -- -R dot",
"test:codecov": "nyc --reporter=cobertura npm run test",
"test:coverage": "nyc npm run test"
"test:coverage": "nyc npm run test:dot"
},
"engines": {
"node": ">=10.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class User {
return;
}

if (data.walletBalance) {
if (undefined !== data.walletBalance) {
this.walletBalance = parseAmount(data.walletBalance);
}
if (undefined !== data.showTermsAndCondition) {
Expand Down
2 changes: 1 addition & 1 deletion src/portokasse/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class PortokasseService extends RestService implements Portokasse {

const res = await this.request('GET', '/api/v1/wallet-overviews/me');

if (res?.balance) {
if (!Number.isNaN(res?.balance)) {
this.user.load({
walletBalance: res.balance
});
Expand Down
16 changes: 16 additions & 0 deletions test/User.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ describe('User', () => {
expect(info.orderIds).to.be.empty;
});

it('should load user data with 0 balance', () => {
const emptydata: UserData = {
walletBalance: 0,
infoMessage: 'msg',
showTermsAndCondition: true,
userToken: '<TOKEN>'
};
user.load(emptydata);

const info = user.getInfo();

expect(info).to.exist;
expect(info.walletBalance).to.exist;
expect(info.walletBalance!.value).to.equal(0);
});

it('should not load data without a valid token', () => {
const infoUpdate = {
walletBalance: 2000
Expand Down

0 comments on commit b35a906

Please sign in to comment.