Page MenuHomePhabricator

[Cashtab] Add unit tests for parseAddressForParams
ClosedPublic

Authored by emack on Jun 25 2023, 01:52.

Details

Summary

As per feedback from D14116, this diff adds unit tests to the existing parseAddressForParams function before moving it out of Ticker.js in D14116.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested review of this revision.Jun 25 2023, 01:52

Tail of the build log:

  SignVerifyMsg.js             |   34.34 |    27.08 |    4.76 |   34.34 | 48,59,67,71,100-131,135-141,147-172,176-177,182-191,195-206,210-232,270-441                                                                                                                                                                                                                                                                                               
 src/components/Tokens         |    28.5 |    30.27 |      16 |   28.76 |                                                                                                                                                                                                                                                                                                                                                                           
  CreateTokenForm.js           |   25.23 |    27.72 |   12.76 |   25.48 | 89,93-122,127,131-214,219-237,242-248,261-277,289-306,314-324,332-337,346-349,373-424,432-474,482-715,751-798,821                                                                                                                                                                                                                                                         
  TokenIcon.js                 |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  Tokens.js                    |    87.5 |     62.5 |      50 |    87.5 | 98                                                                                                                                                                                                                                                                                                                                                                        
 src/config                    |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  chronik.js                   |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  opreturn.js                  |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  token.js                     |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  websocket.js                 |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
 src/hooks                     |   19.53 |       12 |    28.4 |   19.94 |                                                                                                                                                                                                                                                                                                                                                                           
  useImage.js                  |       0 |        0 |       0 |       0 | 1-199                                                                                                                                                                                                                                                                                                                                                                     
  useInnerScroll.js            |       0 |      100 |       0 |       0 | 3-6                                                                                                                                                                                                                                                                                                                                                                       
  useInterval.js               |   88.88 |       50 |      80 |    87.5 | 16                                                                                                                                                                                                                                                                                                                                                                        
  usePrevious.js               |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  useWallet.js                 |   20.53 |    12.43 |   32.65 |   20.96 | 79-107,132-136,146-254,263-264,279-289,293-300,304-314,330-334,347-353,368,404-407,414-421,427-432,441-467,477-501,511-605,609-651,655-717,721-769,773-828,832-860,866-989,1007-1116,1124,1131-1247,1264-1288,1305-1316,1335-1349,1359-1364,1369,1375-1422,1439,1464-1526,1539-1545,1562-1579,1623-1649                                                                   
  useWindowDimensions.js       |   77.77 |      100 |      60 |    87.5 | 21                                                                                                                                                                                                                                                                                                                                                                        
 src/utils                     |    75.5 |    76.23 |   69.17 |    75.5 |                                                                                                                                                                                                                                                                                                                                                                           
  GoogleAnalytics.js           |   22.72 |        0 |       0 |    23.8 | 8-38,53-58,62                                                                                                                                                                                                                                                                                                                                                             
  aliasUtils.js                |   14.28 |      100 |       0 |   14.28 | 14-27,40-53,66-79                                                                                                                                                                                                                                                                                                                                                         
  cashMethods.js               |   91.85 |    87.73 |     100 |   91.66 | 21,55,81-91,96-100,184-186,230,320,345,377-378,468,504,549,694,773-774,865,876,1044,1133,1153,1162,1185,1230,1251-1254,1280-1281                                                                                                                                                                                                                                          
  chronik.js                   |   70.52 |    79.48 |   51.28 |   70.55 | 20-27,40-49,71-90,108,117-121,178-197,206-216,228-240,301,331,407,523-532,610-615,642-645,677-678,710-716,735-738,756,763-764,850-859,908-1022,1053-1054                                                                                                                                                                                                                  
  coininfo.js                  |       0 |        0 |       0 |       0 | 4-72                                                                                                                                                                                                                                                                                                                                                                      
  context.js                   |      60 |      100 |       0 |      60 | 8-9                                                                                                                                                                                                                                                                                                                                                                       
  debounce.js                  |       0 |        0 |       0 |       0 | 4-8                                                                                                                                                                                                                                                                                                                                                                       
  ecashCoinInfo.js             |       0 |      100 |     100 |       0 | 10-113                                                                                                                                                                                                                                                                                                                                                                    
  formatting.js                |   77.77 |    83.33 |     100 |   77.77 | 15,25,43,53,68-70,109-111                                                                                                                                                                                                                                                                                                                                                 
  retry.js                     |       0 |        0 |       0 |       0 | 1-8                                                                                                                                                                                                                                                                                                                                                                       
  tokenMethods.js              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                           
  transactions.js              |   51.19 |    46.87 |   83.33 |    51.8 | 89-93,100,102,104,109,121-189,198,216-258,274-325,403-407,414-427,462-463,480,502-503,582,593,595,597,602                                                                                                                                                                                                                                                                 
  validation.js                |   91.17 |    80.22 |   82.75 |   91.37 | 12,30-31,87-94,131-138,242,277,281-282,316,386,405,412                                                                                                                                                                                                                                                                                                                    
 src/utils/icons               |    2.52 |        0 |       0 |    2.72 |                                                                                                                                                                                                                                                                                                                                                                           
  cropImage.js                 |    2.27 |        0 |       0 |    2.43 | 2-78                                                                                                                                                                                                                                                                                                                                                                      
  resizeImage.js               |    2.77 |        0 |       0 |    3.03 | 2-51                                                                                                                                                                                                                                                                                                                                                                      
  roundImage.js                |    2.56 |        0 |       0 |    2.77 | 2-57                                                                                                                                                                                                                                                                                                                                                                      
-------------------------------|---------|----------|---------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='2088']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='4622']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='887']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2214']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='342']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='986']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='2052']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='4514']
##teamcity[blockClosed name='Code Coverage Summary']

Snapshot Summary
 › 2 snapshots obsolete from 1 test suite. To remove them all, re-run jest with `-u`.
   ↳ src/components/Common/__tests__/Ticker.test.js
       • parseAddressForParams() returns valid info for a valid eCash address: ecash:qq9h6d0a5q65fgywv4ry64x04ep906mdku8f0gxfgx 1
       • parseAddressForParams() returns valid info for a valid prefix-less eCash address: qq9h6d0a5q65fgywv4ry64x04ep906mdku8f0gxfgx 1

Test Suites: 22 passed, 22 total
Tests:       447 passed, 447 total
Snapshots:   2 obsolete, 42 passed, 42 total
Time:        12.072 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

Updated unit test snapshot

Why did the CI failed for snapshot issue ? Also the case parseAddressForParams() returns valid info for a valid prefix-less eCash address: qq9h6d0a5q65fgywv4ry64x04ep906mdku8f0gxfgx 1 seems to not exist ?

added additional unit test for a valid prefix-less eCash address

Why did the CI failed for snapshot issue ?

The CI failure was caused by me not updating the snapshots when I initially created the Ticker.test.js which didn't exist previously

This revision is now accepted and ready to land.Jun 26 2023, 06:25