@@ -8,29 +8,39 @@ import {
8
8
unapprovedPersonalSignMsg ,
9
9
} from '../../../../../test/data/confirmations/personal_sign' ;
10
10
import { SignatureRequestType } from '../../types/confirm' ;
11
- import { getConfirmationSender } from './utils' ;
11
+ import { formatNumber , getConfirmationSender } from './utils' ;
12
12
13
- describe ( 'getConfirmationSender()' , ( ) => {
14
- test ( "returns the sender address from a signature if it's passed" , ( ) => {
15
- const testCurrentConfirmation =
16
- genUnapprovedContractInteractionConfirmation ( ) as TransactionMeta ;
17
- const { from } = getConfirmationSender ( testCurrentConfirmation ) ;
13
+ describe ( 'confirm - utils' , ( ) => {
14
+ describe ( 'getConfirmationSender()' , ( ) => {
15
+ test ( "returns the sender address from a signature if it's passed" , ( ) => {
16
+ const testCurrentConfirmation =
17
+ genUnapprovedContractInteractionConfirmation ( ) as TransactionMeta ;
18
+ const { from } = getConfirmationSender ( testCurrentConfirmation ) ;
18
19
19
- expect ( from ) . toEqual ( CONTRACT_INTERACTION_SENDER_ADDRESS ) ;
20
- } ) ;
20
+ expect ( from ) . toEqual ( CONTRACT_INTERACTION_SENDER_ADDRESS ) ;
21
+ } ) ;
21
22
22
- test ( "returns the sender address from a transaction if it's passed" , ( ) => {
23
- const { from } = getConfirmationSender (
24
- unapprovedPersonalSignMsg as SignatureRequestType ,
25
- ) ;
23
+ test ( "returns the sender address from a transaction if it's passed" , ( ) => {
24
+ const { from } = getConfirmationSender (
25
+ unapprovedPersonalSignMsg as SignatureRequestType ,
26
+ ) ;
26
27
27
- expect ( from ) . toEqual ( PERSONAL_SIGN_SENDER_ADDRESS ) ;
28
- } ) ;
28
+ expect ( from ) . toEqual ( PERSONAL_SIGN_SENDER_ADDRESS ) ;
29
+ } ) ;
29
30
30
- test ( 'returns no sender address if no confirmation is passed' , ( ) => {
31
- const testCurrentConfirmation = undefined ;
32
- const { from } = getConfirmationSender ( testCurrentConfirmation ) ;
31
+ test ( 'returns no sender address if no confirmation is passed' , ( ) => {
32
+ const testCurrentConfirmation = undefined ;
33
+ const { from } = getConfirmationSender ( testCurrentConfirmation ) ;
34
+
35
+ expect ( from ) . toEqual ( undefined ) ;
36
+ } ) ;
37
+ } ) ;
33
38
34
- expect ( from ) . toEqual ( undefined ) ;
39
+ describe ( 'formatNumber()' , ( ) => {
40
+ test ( 'formats number according to decimal places passed' , ( ) => {
41
+ expect ( formatNumber ( 123456 , 2 ) ) . toEqual ( '123,456.00' ) ;
42
+ expect ( formatNumber ( 123456 , 0 ) ) . toEqual ( '123,456' ) ;
43
+ expect ( formatNumber ( 123456 , 7 ) ) . toEqual ( '123,456.0000000' ) ;
44
+ } ) ;
35
45
} ) ;
36
46
} ) ;
0 commit comments