@@ -175,23 +175,54 @@ describe('Action Payments Unit Tests', () => {
175175 } ) ;
176176
177177 describe ( 'initPayBitcoinConfirm()' , ( ) => {
178- it ( 'should get estimate and navigate to confirm view' , async ( ) => {
178+ beforeEach ( ( ) => {
179179 store . payment . address = 'foo' ;
180180 store . payment . amount = '2000' ;
181181 grpc . sendCommand . withArgs ( 'estimateFee' ) . resolves ( {
182182 feeSat : 10000 ,
183183 } ) ;
184+ } ) ;
185+
186+ it ( 'should get estimate and navigate to confirm view' , async ( ) => {
187+ await payment . initPayBitcoinConfirm ( ) ;
188+ expect ( grpc . sendCommand , 'was called once' ) ;
189+ expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
190+ expect ( notification . display , 'was not called' ) ;
191+ expect ( store . payment . fee , 'to be' , '0.0001' ) ;
192+ } ) ;
193+
194+ it ( 'should not get estimate and navigate if fee and sendAll are set' , async ( ) => {
195+ store . payment . fee = '0.0002' ;
196+ store . payment . sendAll = true ;
197+ await payment . initPayBitcoinConfirm ( ) ;
198+ expect ( grpc . sendCommand , 'was not called' ) ;
199+ expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
200+ expect ( notification . display , 'was not called' ) ;
201+ expect ( store . payment . fee , 'to be' , '0.0002' ) ;
202+ } ) ;
203+
204+ it ( 'should get estimate and navigate if fee is set' , async ( ) => {
205+ store . payment . fee = '0.0002' ;
184206 await payment . initPayBitcoinConfirm ( ) ;
207+ expect ( grpc . sendCommand , 'was called once' ) ;
208+ expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
209+ expect ( notification . display , 'was not called' ) ;
210+ expect ( store . payment . fee , 'to be' , '0.0001' ) ;
211+ } ) ;
212+
213+ it ( 'should get estimate and navigate if sendAll is set' , async ( ) => {
214+ store . payment . sendAll = true ;
215+ await payment . initPayBitcoinConfirm ( ) ;
216+ expect ( grpc . sendCommand , 'was called once' ) ;
185217 expect ( nav . goPayBitcoinConfirm , 'was called once' ) ;
186218 expect ( notification . display , 'was not called' ) ;
187219 expect ( store . payment . fee , 'to be' , '0.0001' ) ;
188220 } ) ;
189221
190222 it ( 'should display notification on error' , async ( ) => {
191- store . payment . address = 'foo' ;
192- store . payment . amount = '2000' ;
193223 grpc . sendCommand . withArgs ( 'estimateFee' ) . rejects ( ) ;
194224 await payment . initPayBitcoinConfirm ( ) ;
225+ expect ( grpc . sendCommand , 'was called once' ) ;
195226 expect ( nav . goPayBitcoinConfirm , 'was not called' ) ;
196227 expect ( notification . display , 'was called once' ) ;
197228 expect ( store . payment . fee , 'to be' , '' ) ;
0 commit comments