@@ -15,14 +15,21 @@ describe('onboard/_helpers', () => {
1515 } )
1616
1717 test ( 'handles auth code with dots in fingerprint id' , ( ) => {
18- // Note: This is a potential edge case - the current implementation
19- // only splits into 3 parts, so extra dots would be included in fingerprintId
2018 const authCode = 'fp.with.dots.1704067200000.hashvalue'
2119 const result = parseAuthCode ( authCode )
2220
23- expect ( result . fingerprintId ) . toBe ( 'fp' )
24- expect ( result . expiresAt ) . toBe ( 'with' )
25- expect ( result . receivedHash ) . toBe ( 'dots' )
21+ expect ( result . fingerprintId ) . toBe ( 'fp.with.dots' )
22+ expect ( result . expiresAt ) . toBe ( '1704067200000' )
23+ expect ( result . receivedHash ) . toBe ( 'hashvalue' )
24+ } )
25+
26+ test ( 'trims surrounding whitespace from copied auth code' , ( ) => {
27+ const authCode = '\n fingerprint-123.1704067200000.abc123hash \t'
28+ const result = parseAuthCode ( authCode )
29+
30+ expect ( result . fingerprintId ) . toBe ( 'fingerprint-123' )
31+ expect ( result . expiresAt ) . toBe ( '1704067200000' )
32+ expect ( result . receivedHash ) . toBe ( 'abc123hash' )
2633 } )
2734
2835 test ( 'handles empty string parts' , ( ) => {
@@ -38,27 +45,27 @@ describe('onboard/_helpers', () => {
3845 const authCode = 'onlyonepart'
3946 const result = parseAuthCode ( authCode )
4047
41- expect ( result . fingerprintId ) . toBe ( 'onlyonepart ' )
42- expect ( result . expiresAt ) . toBeUndefined ( )
43- expect ( result . receivedHash ) . toBeUndefined ( )
48+ expect ( result . fingerprintId ) . toBe ( '' )
49+ expect ( result . expiresAt ) . toBe ( '' )
50+ expect ( result . receivedHash ) . toBe ( '' )
4451 } )
4552
4653 test ( 'handles auth code with two parts' , ( ) => {
4754 const authCode = 'first.second'
4855 const result = parseAuthCode ( authCode )
4956
50- expect ( result . fingerprintId ) . toBe ( 'first ' )
51- expect ( result . expiresAt ) . toBe ( 'second ' )
52- expect ( result . receivedHash ) . toBeUndefined ( )
57+ expect ( result . fingerprintId ) . toBe ( '' )
58+ expect ( result . expiresAt ) . toBe ( '' )
59+ expect ( result . receivedHash ) . toBe ( '' )
5360 } )
5461
5562 test ( 'handles empty auth code' , ( ) => {
5663 const authCode = ''
5764 const result = parseAuthCode ( authCode )
5865
5966 expect ( result . fingerprintId ) . toBe ( '' )
60- expect ( result . expiresAt ) . toBeUndefined ( )
61- expect ( result . receivedHash ) . toBeUndefined ( )
67+ expect ( result . expiresAt ) . toBe ( '' )
68+ expect ( result . receivedHash ) . toBe ( '' )
6269 } )
6370 } )
6471
0 commit comments