@@ -161,19 +161,54 @@ describe('Action Payments Unit Tests', () => {
161161 store . payment . amount = 'bar' ;
162162 store . payment . note = 'baz' ;
163163 store . payment . fee = 'blub' ;
164+ store . payment . targetConf = 1 ;
164165 store . payment . useScanner = true ;
165166 store . payment . sendAll = true ;
166167 payment . init ( ) ;
167168 expect ( store . payment . address , 'to equal' , '' ) ;
168169 expect ( store . payment . amount , 'to equal' , '' ) ;
169170 expect ( store . payment . note , 'to equal' , '' ) ;
170171 expect ( store . payment . fee , 'to equal' , '' ) ;
171- expect ( store . payment . useScanner , 'to equal' , false ) ;
172+ expect ( store . payment . fee , 'to equal' , '' ) ;
173+ expect ( store . payment . targetConf , 'to equal' , 16 ) ;
172174 expect ( store . payment . sendAll , 'to equal' , false ) ;
173175 expect ( nav . goPay , 'was called once' ) ;
174176 } ) ;
175177 } ) ;
176178
179+ describe ( 'estimateFee()' , ( ) => {
180+ beforeEach ( ( ) => {
181+ store . payment . address = 'foo' ;
182+ store . payment . amount = '2000' ;
183+ grpc . sendCommand . withArgs ( 'estimateFee' ) . resolves ( {
184+ feeSat : 10000 ,
185+ } ) ;
186+ } ) ;
187+
188+ it ( 'should get three fee estimates' , async ( ) => {
189+ await payment . estimateFee ( ) ;
190+ expect ( grpc . sendCommand , 'was called thrice' ) ;
191+ expect ( store . payment . feeEstimates [ 0 ] . prio , 'to equal' , 'Low' ) ;
192+ expect ( store . payment . feeEstimates [ 1 ] . prio , 'to equal' , 'Med' ) ;
193+ expect ( store . payment . feeEstimates [ 2 ] . prio , 'to equal' , 'High' ) ;
194+ } ) ;
195+ } ) ;
196+
197+ describe ( 'setTargetConf()' , ( ) => {
198+ it ( 'should set target conf and fee' , async ( ) => {
199+ store . payment . feeEstimates = [ { targetConf : 6 , fee : '42' } ] ;
200+ await payment . setTargetConf ( { targetConf : 6 } ) ;
201+ expect ( store . payment . targetConf , 'to equal' , 6 ) ;
202+ expect ( store . payment . fee , 'to equal' , '42' ) ;
203+ } ) ;
204+
205+ it ( 'should set target conf but not fee if not estimates' , async ( ) => {
206+ await payment . setTargetConf ( { targetConf : 6 } ) ;
207+ expect ( store . payment . targetConf , 'to equal' , 6 ) ;
208+ expect ( store . payment . fee , 'to equal' , '' ) ;
209+ } ) ;
210+ } ) ;
211+
177212 describe ( 'initPayBitcoinConfirm()' , ( ) => {
178213 beforeEach ( ( ) => {
179214 store . payment . address = 'foo' ;
@@ -185,7 +220,7 @@ describe('Action Payments Unit Tests', () => {
185220
186221 it ( 'should get estimate and navigate to confirm view' , async ( ) => {
187222 await payment . initPayBitcoinConfirm ( ) ;
188- expect ( grpc . sendCommand , 'was called once ' ) ;
223+ expect ( grpc . sendCommand , 'was called thrice ' ) ;
189224 expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
190225 expect ( notification . display , 'was not called' ) ;
191226 expect ( store . payment . fee , 'to be' , '0.0001' ) ;
@@ -204,7 +239,7 @@ describe('Action Payments Unit Tests', () => {
204239 it ( 'should get estimate and navigate if fee is set' , async ( ) => {
205240 store . payment . fee = '0.0002' ;
206241 await payment . initPayBitcoinConfirm ( ) ;
207- expect ( grpc . sendCommand , 'was called once ' ) ;
242+ expect ( grpc . sendCommand , 'was called thrice ' ) ;
208243 expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
209244 expect ( notification . display , 'was not called' ) ;
210245 expect ( store . payment . fee , 'to be' , '0.0001' ) ;
@@ -213,7 +248,7 @@ describe('Action Payments Unit Tests', () => {
213248 it ( 'should get estimate and navigate if sendAll is set' , async ( ) => {
214249 store . payment . sendAll = true ;
215250 await payment . initPayBitcoinConfirm ( ) ;
216- expect ( grpc . sendCommand , 'was called once ' ) ;
251+ expect ( grpc . sendCommand , 'was called thrice ' ) ;
217252 expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
218253 expect ( notification . display , 'was not called' ) ;
219254 expect ( store . payment . fee , 'to be' , '0.0001' ) ;
0 commit comments