@@ -66,6 +66,12 @@ const mockSpendingAccounts = [
6666 mockMixedAccount ,
6767 mockUnMixedAccount
6868] ;
69+
70+ const mockVisibleAccounts = [
71+ mockDefaultAccount ,
72+ mockMixedAccount ,
73+ mockUnMixedAccount
74+ ] ;
6975const mockCsppServer = "mockCsppServer.decred.org" ;
7076const mockCsppPort = "1234" ;
7177const mockMixedAccountBranch = 0 ;
@@ -83,6 +89,7 @@ let mockDispatchSingleMessage;
8389beforeEach ( ( ) => {
8490 selectors . currencyDisplay = jest . fn ( ( ) => DCR ) ;
8591 selectors . defaultSpendingAccount = jest . fn ( ( ) => mockMixedAccount ) ;
92+ selectors . visibleAccounts = jest . fn ( ( ) => mockVisibleAccounts ) ;
8693 selectors . getPrivacyEnabled = jest . fn ( ( ) => true ) ;
8794 selectors . isWatchingOnly = jest . fn ( ( ) => false ) ;
8895 selectors . getMixedAccountName = jest . fn ( ( ) => mockMixedAccount . name ) ;
@@ -91,7 +98,6 @@ beforeEach(() => {
9198 selectors . walletService = jest . fn ( ( ) => {
9299 return { } ;
93100 } ) ;
94- selectors . nextAddressAccount = jest . fn ( ( ) => mockUnMixedAccount ) ;
95101 selectors . nextAddress = jest . fn ( ( ) => mockNextAddress ) ;
96102 selectors . getRunningIndicator = jest . fn ( ( ) => false ) ;
97103
@@ -235,7 +241,16 @@ test("test insufficient unmixed account balance error message", async () => {
235241 ( acc ) => acc . value == acctId
236242 )
237243 ) ;
238- render ( < PrivacyTab /> ) ;
244+ render ( < PrivacyTab /> , {
245+ initialState : {
246+ control : {
247+ getNextAddressResponse : {
248+ accountNumber : mockUnMixedAccount . value
249+ }
250+ }
251+ }
252+ } ) ;
253+
239254 await waitFor ( ( ) =>
240255 expect ( screen . getByText ( "Unmixed Balance" ) . parentNode . className ) . toMatch (
241256 / b a l a n c e E r r o r / i
@@ -248,7 +263,16 @@ test("test insufficient unmixed account balance error message", async () => {
248263} ) ;
249264
250265test ( "start coin mixer" , async ( ) => {
251- const { user } = render ( < PrivacyTab /> ) ;
266+ const { user } = render ( < PrivacyTab /> , {
267+ initialState : {
268+ control : {
269+ getNextAddressResponse : {
270+ accountNumber : mockDefaultAccount . value
271+ }
272+ }
273+ }
274+ } ) ;
275+
252276 await waitFor ( ( ) =>
253277 expect (
254278 screen . getByText ( "Unmixed Balance" ) . parentNode . className
@@ -289,7 +313,15 @@ test("start coin mixer", async () => {
289313
290314test ( "stop coin mixer" , async ( ) => {
291315 selectors . getAccountMixerRunning = jest . fn ( ( ) => true ) ;
292- const { user } = render ( < PrivacyTab /> ) ;
316+ const { user } = render ( < PrivacyTab /> , {
317+ initialState : {
318+ control : {
319+ getNextAddressResponse : {
320+ accountNumber : mockDefaultAccount . value
321+ }
322+ }
323+ }
324+ } ) ;
293325
294326 expect ( screen . getByText ( "Mixer is running" ) ) . toBeInTheDocument ( ) ;
295327 await user . click ( getStopMixerButton ( ) ) ;
@@ -299,14 +331,30 @@ test("stop coin mixer", async () => {
299331
300332test ( "mixer is disabled (Autobuyer running)" , ( ) => {
301333 selectors . getRunningIndicator = jest . fn ( ( ) => true ) ;
302- render ( < PrivacyTab /> ) ;
334+ render ( < PrivacyTab /> , {
335+ initialState : {
336+ control : {
337+ getNextAddressResponse : {
338+ accountNumber : mockDefaultAccount . value
339+ }
340+ }
341+ }
342+ } ) ;
303343
304344 expect ( getSendToSelfButton ( ) . disabled ) . toBe ( true ) ;
305345 expect ( getStartMixerButton ( ) . disabled ) . toBe ( true ) ;
306346} ) ;
307347
308348test ( "allow sending from unmixed accounts" , async ( ) => {
309- const { user } = render ( < PrivacyTab /> ) ;
349+ const { user } = render ( < PrivacyTab /> , {
350+ initialState : {
351+ control : {
352+ getNextAddressResponse : {
353+ accountNumber : mockDefaultAccount . value
354+ }
355+ }
356+ }
357+ } ) ;
310358
311359 const checkbox = getPrivacyCheckbox ( ) ;
312360
@@ -333,7 +381,15 @@ test("allow sending from unmixed accounts", async () => {
333381
334382test ( "sending from unmixed accounts is allowed already" , async ( ) => {
335383 selectors . getAllowSendFromUnmixed = jest . fn ( ( ) => true ) ;
336- const { user } = render ( < PrivacyTab /> ) ;
384+ const { user } = render ( < PrivacyTab /> , {
385+ initialState : {
386+ control : {
387+ getNextAddressResponse : {
388+ accountNumber : mockDefaultAccount . value
389+ }
390+ }
391+ }
392+ } ) ;
337393
338394 const checkbox = getPrivacyCheckbox ( ) ;
339395 expect ( checkbox . checked ) . toBe ( true ) ;
@@ -343,7 +399,16 @@ test("sending from unmixed accounts is allowed already", async () => {
343399} ) ;
344400
345401test ( "Send to Unmixed Account form" , async ( ) => {
346- const { user } = render ( < PrivacyTab /> ) ;
402+ const { user } = render ( < PrivacyTab /> , {
403+ initialState : {
404+ control : {
405+ getNextAddressResponse : {
406+ accountNumber : mockDefaultAccount . value
407+ }
408+ }
409+ }
410+ } ) ;
411+
347412 const sendToSelfBtn = getSendToSelfButton ( ) ;
348413 const amountInput = screen . getByLabelText ( "Amount:" ) ;
349414 const testAmount = "12" ;
@@ -372,7 +437,15 @@ test("check logs", async () => {
372437 mockGetPrivacyLogs = wallet . getPrivacyLogs = jest . fn ( ( ) =>
373438 Promise . resolve ( mockLogLine )
374439 ) ;
375- const { user } = render ( < PrivacyTab /> ) ;
440+ const { user } = render ( < PrivacyTab /> , {
441+ initialState : {
442+ control : {
443+ getNextAddressResponse : {
444+ accountNumber : mockDefaultAccount . value
445+ }
446+ }
447+ }
448+ } ) ;
376449
377450 const logsLabel = screen . getByText ( "Logs" ) ;
378451
0 commit comments