Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
lightning-bits
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
lightning-bits
Commits
060af8d0
Commit
060af8d0
authored
Aug 30, 2019
by
Tankred Hase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing unit tests
parent
f8391f24
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
4 deletions
+59
-4
payment.js
src/action/payment.js
+1
-0
payment.spec.js
test/unit/action/payment.spec.js
+39
-4
payment.spec.js
test/unit/computed/payment.spec.js
+19
-0
No files found.
src/action/payment.js
View file @
060af8d0
...
...
@@ -256,6 +256,7 @@ class PaymentAction {
setTargetConf
({
targetConf
})
{
const
{
payment
}
=
this
.
_store
;
payment
.
targetConf
=
targetConf
;
if
(
!
payment
.
feeEstimates
.
length
)
return
;
payment
.
fee
=
payment
.
feeEstimates
.
find
(
e
=>
e
.
targetConf
===
targetConf
).
fee
;
...
...
test/unit/action/payment.spec.js
View file @
060af8d0
...
...
@@ -161,6 +161,7 @@ describe('Action Payments Unit Tests', () => {
store
.
payment
.
amount
=
'bar'
;
store
.
payment
.
note
=
'baz'
;
store
.
payment
.
fee
=
'blub'
;
store
.
payment
.
targetConf
=
1
;
store
.
payment
.
useScanner
=
true
;
store
.
payment
.
sendAll
=
true
;
payment
.
init
();
...
...
@@ -168,12 +169,46 @@ describe('Action Payments Unit Tests', () => {
expect
(
store
.
payment
.
amount
,
'to equal'
,
''
);
expect
(
store
.
payment
.
note
,
'to equal'
,
''
);
expect
(
store
.
payment
.
fee
,
'to equal'
,
''
);
expect
(
store
.
payment
.
useScanner
,
'to equal'
,
false
);
expect
(
store
.
payment
.
fee
,
'to equal'
,
''
);
expect
(
store
.
payment
.
targetConf
,
'to equal'
,
16
);
expect
(
store
.
payment
.
sendAll
,
'to equal'
,
false
);
expect
(
nav
.
goPay
,
'was called once'
);
});
});
describe
(
'estimateFee()'
,
()
=>
{
beforeEach
(()
=>
{
store
.
payment
.
address
=
'foo'
;
store
.
payment
.
amount
=
'2000'
;
grpc
.
sendCommand
.
withArgs
(
'estimateFee'
).
resolves
({
feeSat
:
10000
,
});
});
it
(
'should get three fee estimates'
,
async
()
=>
{
await
payment
.
estimateFee
();
expect
(
grpc
.
sendCommand
,
'was called thrice'
);
expect
(
store
.
payment
.
feeEstimates
[
0
].
prio
,
'to equal'
,
'Low'
);
expect
(
store
.
payment
.
feeEstimates
[
1
].
prio
,
'to equal'
,
'Med'
);
expect
(
store
.
payment
.
feeEstimates
[
2
].
prio
,
'to equal'
,
'High'
);
});
});
describe
(
'setTargetConf()'
,
()
=>
{
it
(
'should set target conf and fee'
,
async
()
=>
{
store
.
payment
.
feeEstimates
=
[{
targetConf
:
6
,
fee
:
'42'
}];
await
payment
.
setTargetConf
({
targetConf
:
6
});
expect
(
store
.
payment
.
targetConf
,
'to equal'
,
6
);
expect
(
store
.
payment
.
fee
,
'to equal'
,
'42'
);
});
it
(
'should set target conf but not fee if not estimates'
,
async
()
=>
{
await
payment
.
setTargetConf
({
targetConf
:
6
});
expect
(
store
.
payment
.
targetConf
,
'to equal'
,
6
);
expect
(
store
.
payment
.
fee
,
'to equal'
,
''
);
});
});
describe
(
'initPayBitcoinConfirm()'
,
()
=>
{
beforeEach
(()
=>
{
store
.
payment
.
address
=
'foo'
;
...
...
@@ -185,7 +220,7 @@ describe('Action Payments Unit Tests', () => {
it
(
'should get estimate and navigate to confirm view'
,
async
()
=>
{
await
payment
.
initPayBitcoinConfirm
();
expect
(
grpc
.
sendCommand
,
'was called
on
ce'
);
expect
(
grpc
.
sendCommand
,
'was called
thri
ce'
);
expect
(
nav
.
goPayBitcoinConfirm
,
'was called once'
);
expect
(
notification
.
display
,
'was not called'
);
expect
(
store
.
payment
.
fee
,
'to be'
,
'0.0001'
);
...
...
@@ -204,7 +239,7 @@ describe('Action Payments Unit Tests', () => {
it
(
'should get estimate and navigate if fee is set'
,
async
()
=>
{
store
.
payment
.
fee
=
'0.0002'
;
await
payment
.
initPayBitcoinConfirm
();
expect
(
grpc
.
sendCommand
,
'was called
on
ce'
);
expect
(
grpc
.
sendCommand
,
'was called
thri
ce'
);
expect
(
nav
.
goPayBitcoinConfirm
,
'was called once'
);
expect
(
notification
.
display
,
'was not called'
);
expect
(
store
.
payment
.
fee
,
'to be'
,
'0.0001'
);
...
...
@@ -213,7 +248,7 @@ describe('Action Payments Unit Tests', () => {
it
(
'should get estimate and navigate if sendAll is set'
,
async
()
=>
{
store
.
payment
.
sendAll
=
true
;
await
payment
.
initPayBitcoinConfirm
();
expect
(
grpc
.
sendCommand
,
'was called
on
ce'
);
expect
(
grpc
.
sendCommand
,
'was called
thri
ce'
);
expect
(
nav
.
goPayBitcoinConfirm
,
'was called once'
);
expect
(
notification
.
display
,
'was not called'
);
expect
(
store
.
payment
.
fee
,
'to be'
,
'0.0001'
);
...
...
test/unit/computed/payment.spec.js
View file @
060af8d0
...
...
@@ -14,10 +14,29 @@ describe('Computed Payment Unit Tests', () => {
it
(
'should work with initial store'
,
()
=>
{
ComputedPayment
(
store
);
expect
(
store
.
paymentAmountLabel
,
'to equal'
,
'0'
);
expect
(
store
.
paymentFeeEstimateItems
,
'to equal'
,
[]);
expect
(
store
.
paymentFeeLabel
,
'to equal'
,
'0'
);
expect
(
store
.
paymentTotalLabel
,
'to equal'
,
'0'
);
});
it
(
'should calculate fee estimate label'
,
()
=>
{
store
.
unitLabel
=
'sats'
;
store
.
payment
.
feeEstimates
=
[
{
fee
:
'10'
,
targetConf
:
6
,
prio
:
'Med'
,
},
];
ComputedPayment
(
store
);
expect
(
store
.
paymentFeeEstimateItems
[
0
].
label
,
'to match'
,
/^Med 10 sats$/
);
expect
(
store
.
paymentFeeEstimateItems
[
0
].
value
,
'to equal'
,
6
);
});
it
(
'should calculate btc total'
,
()
=>
{
store
.
payment
.
fee
=
'0.0001'
;
store
.
payment
.
amount
=
'0.1'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment