Skip to content

Commit b35a906

Browse files
committed
fix: update user wallet balance if a zero euros
1 parent da4fa96 commit b35a906

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.0] - 2021-08-20
9+
10+
### Added
11+
12+
- Shopping cart matches product with receiver address to avoid wrong vouchers
13+
14+
### Fixed
15+
16+
- User did not set wallet balance if it was empty with zero Euros
17+
818
## [0.7.1] - 2021-08-20
919

1020
### Fixed

SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Until then only the latest 0.x minor release is supported.
88

99
| Version | Supported |
1010
| ------- | ------------------ |
11+
| 0.8.x | :white_check_mark: |
1112
| 0.7.x | :white_check_mark: |
1213
| < 0.7 | :x: |
1314

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "internetmarke",
3-
"version": "0.7.1",
3+
"version": "0.8.0",
44
"description": "A node implementation to use the Internetmarke web service of Deutsche Post.",
55
"keywords": [
66
"internetmarke",
@@ -31,7 +31,7 @@
3131
"test": "mocha -r ts-node/register 'test/**/*.spec.ts'",
3232
"test:dot": "npm run test -- -R dot",
3333
"test:codecov": "nyc --reporter=cobertura npm run test",
34-
"test:coverage": "nyc npm run test"
34+
"test:coverage": "nyc npm run test:dot"
3535
},
3636
"engines": {
3737
"node": ">=10.0.0"

src/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class User {
7878
return;
7979
}
8080

81-
if (data.walletBalance) {
81+
if (undefined !== data.walletBalance) {
8282
this.walletBalance = parseAmount(data.walletBalance);
8383
}
8484
if (undefined !== data.showTermsAndCondition) {

src/portokasse/Service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class PortokasseService extends RestService implements Portokasse {
8787

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

90-
if (res?.balance) {
90+
if (!Number.isNaN(res?.balance)) {
9191
this.user.load({
9292
walletBalance: res.balance
9393
});

test/User.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ describe('User', () => {
4646
expect(info.orderIds).to.be.empty;
4747
});
4848

49+
it('should load user data with 0 balance', () => {
50+
const emptydata: UserData = {
51+
walletBalance: 0,
52+
infoMessage: 'msg',
53+
showTermsAndCondition: true,
54+
userToken: '<TOKEN>'
55+
};
56+
user.load(emptydata);
57+
58+
const info = user.getInfo();
59+
60+
expect(info).to.exist;
61+
expect(info.walletBalance).to.exist;
62+
expect(info.walletBalance!.value).to.equal(0);
63+
});
64+
4965
it('should not load data without a valid token', () => {
5066
const infoUpdate = {
5167
walletBalance: 2000

0 commit comments

Comments
 (0)