@@ -3,64 +3,79 @@ import {client} from './utils'
3
3
import { WhitelistType } from '../src'
4
4
import { POLICY_UUID , ACCOUNT_ADDRESS , CONTRACT_METHOD } from './env'
5
5
6
-
7
6
/**
8
- * test sponsor apis
7
+ * Test suite for Sponsor API methods involving whitelist management and spend data retrieval.
9
8
*/
10
-
11
9
describe ( 'sponsorQuery' , ( ) => {
10
+ /**
11
+ * Tests adding an account address to the 'From Account' whitelist.
12
+ */
12
13
describe ( 'addToWhitelist FromAccountWhitelist' , ( ) => {
13
- test ( 'it works ' , async ( ) => {
14
+ test ( 'should add an account address to FromAccountWhitelist successfully ' , async ( ) => {
14
15
const res = await client . addToWhitelist ( {
15
16
PolicyUUID : POLICY_UUID ,
16
17
WhitelistType : WhitelistType . FromAccountWhitelist ,
17
18
Values : [ ACCOUNT_ADDRESS ] ,
18
19
} )
19
20
20
21
expect ( res ) . toEqual ( true )
21
- console . log ( res )
22
+ console . log ( 'FromAccountWhitelist addition response:' , res )
22
23
} )
23
24
} )
24
25
26
+ /**
27
+ * Tests adding an account address to the 'To Account' whitelist.
28
+ */
25
29
describe ( 'addToWhitelist ToAccountWhitelist' , ( ) => {
26
- test ( 'it works ' , async ( ) => {
30
+ test ( 'should add an account address to ToAccountWhitelist successfully ' , async ( ) => {
27
31
const res = await client . addToWhitelist ( {
28
32
PolicyUUID : POLICY_UUID ,
29
33
WhitelistType : WhitelistType . ToAccountWhitelist ,
30
34
Values : [ ACCOUNT_ADDRESS ] ,
31
35
} )
32
36
33
37
expect ( res ) . toEqual ( true )
34
- console . log ( res )
38
+ console . log ( 'ToAccountWhitelist addition response:' , res )
35
39
} )
36
40
} )
41
+
42
+ /**
43
+ * Tests adding an account address to the BEP20 receiver whitelist.
44
+ */
37
45
describe ( 'addToWhitelist BEP20ReceiverWhiteList' , ( ) => {
38
- test ( 'it works ' , async ( ) => {
46
+ test ( 'should add an account address to BEP20ReceiverWhiteList successfully ' , async ( ) => {
39
47
const res = await client . addToWhitelist ( {
40
48
PolicyUUID : POLICY_UUID ,
41
49
WhitelistType : WhitelistType . BEP20ReceiverWhiteList ,
42
50
Values : [ ACCOUNT_ADDRESS ] ,
43
51
} )
44
52
45
53
expect ( res ) . toEqual ( true )
46
- console . log ( res )
54
+ console . log ( 'BEP20ReceiverWhiteList addition response:' , res )
47
55
} )
48
56
} )
49
57
58
+ /**
59
+ * Tests adding a contract method signature to the whitelist.
60
+ */
50
61
describe ( 'addToWhitelist ContractMethodSigWhitelist' , ( ) => {
51
- test ( 'it works ' , async ( ) => {
62
+ test ( 'should add a contract method signature to ContractMethodSigWhitelist successfully ' , async ( ) => {
52
63
const res = await client . addToWhitelist ( {
53
64
PolicyUUID : POLICY_UUID ,
54
65
WhitelistType : WhitelistType . ContractMethodSigWhitelist ,
55
66
Values : [ CONTRACT_METHOD ] ,
56
67
} )
57
68
58
69
expect ( res ) . toEqual ( true )
70
+ console . log ( 'ContractMethodSigWhitelist addition response:' , res )
59
71
} )
60
72
} )
61
73
74
+ /**
75
+ * Tests retrieving whitelists of contract method signatures.
76
+ */
62
77
describe ( 'getWhitelist' , ( ) => {
63
- test ( 'it works ' , async ( ) => {
78
+ test ( 'should retrieve contract method signatures successfully ' , async ( ) => {
64
79
const res = await client . getWhitelist ( {
65
80
PolicyUUID : POLICY_UUID ,
66
81
WhitelistType : WhitelistType . ContractMethodSigWhitelist ,
@@ -69,23 +84,31 @@ describe('sponsorQuery', () => {
69
84
} )
70
85
71
86
expect ( res [ 0 ] ) . toEqual ( CONTRACT_METHOD )
87
+ console . log ( 'Retrieved ContractMethodSigWhitelist:' , res )
72
88
} )
73
89
} )
74
90
91
+ /**
92
+ * Tests removing an account address from a whitelist.
93
+ */
75
94
describe ( 'removeFromWhitelist' , ( ) => {
76
- test ( 'it works ' , async ( ) => {
95
+ test ( 'should remove an account address from FromAccountWhitelist successfully ' , async ( ) => {
77
96
const res = await client . removeFromWhitelist ( {
78
97
PolicyUUID : POLICY_UUID ,
79
98
WhitelistType : WhitelistType . FromAccountWhitelist ,
80
99
Values : [ ACCOUNT_ADDRESS ] ,
81
100
} )
82
101
83
102
expect ( res ) . toEqual ( true )
103
+ console . log ( 'FromAccountWhitelist removal response:' , res )
84
104
} )
85
105
} )
86
106
107
+ /**
108
+ * Tests verifying the removal of an account address from a whitelist.
109
+ */
87
110
describe ( 'getWhitelist' , ( ) => {
88
- test ( 'it works ' , async ( ) => {
111
+ test ( 'should not contain account address post-removal ' , async ( ) => {
89
112
const res = await client . getWhitelist ( {
90
113
PolicyUUID : POLICY_UUID ,
91
114
WhitelistType : WhitelistType . FromAccountWhitelist ,
@@ -95,22 +118,30 @@ describe('sponsorQuery', () => {
95
118
if ( res !== null && res !== undefined ) {
96
119
expect ( res ) . not . toContain ( ACCOUNT_ADDRESS )
97
120
}
121
+ console . log ( 'FromAccountWhitelist post-removal check:' , res )
98
122
} )
99
123
} )
100
124
125
+ /**
126
+ * Tests clearing all entries from a specific whitelist type.
127
+ */
101
128
describe ( 'emptyWhitelist' , ( ) => {
102
- test ( 'it works ' , async ( ) => {
129
+ test ( 'should clear all entries from BEP20ReceiverWhiteList successfully ' , async ( ) => {
103
130
const res = await client . emptyWhitelist ( {
104
131
PolicyUUID : POLICY_UUID ,
105
132
WhitelistType : WhitelistType . BEP20ReceiverWhiteList ,
106
133
} )
107
134
108
135
expect ( res ) . toEqual ( true )
136
+ console . log ( 'BEP20ReceiverWhiteList clearance response:' , res )
109
137
} )
110
138
} )
111
139
140
+ /**
141
+ * Tests verifying the emptiness of a whitelist.
142
+ */
112
143
describe ( 'getWhitelist' , ( ) => {
113
- test ( 'it works ' , async ( ) => {
144
+ test ( 'should confirm the whitelist is empty ' , async ( ) => {
114
145
const res = await client . getWhitelist ( {
115
146
PolicyUUID : POLICY_UUID ,
116
147
WhitelistType : WhitelistType . BEP20ReceiverWhiteList ,
@@ -119,34 +150,46 @@ describe('sponsorQuery', () => {
119
150
} )
120
151
121
152
expect ( res ) . toBeNull ( )
153
+ console . log ( 'BEP20ReceiverWhiteList emptiness check:' , res )
122
154
} )
123
155
} )
124
156
157
+ /**
158
+ * Tests retrieving user spend data.
159
+ */
125
160
describe ( 'getUserSpendData' , ( ) => {
126
- test ( 'it works ' , async ( ) => {
161
+ test ( 'should return null for spend data when user has none ' , async ( ) => {
127
162
const res = await client . getUserSpendData ( ACCOUNT_ADDRESS , POLICY_UUID )
128
163
129
164
expect ( res ) . toBeNull ( )
165
+ console . log ( 'User spend data:' , res )
130
166
} )
131
167
} )
132
168
169
+ /**
170
+ * Tests retrieving policy spend data.
171
+ */
133
172
describe ( 'getPolicySpendData' , ( ) => {
134
- test ( 'it works ' , async ( ) => {
173
+ test ( 'should retrieve policy spend data successfully ' , async ( ) => {
135
174
const res = await client . getPolicySpendData ( POLICY_UUID )
136
175
expect ( res . ChainID ) . not . toBeNull ( )
176
+ console . log ( 'Policy spend data:' , res )
137
177
} )
138
178
} )
139
179
180
+ /**
181
+ * Tests re-adding an account address to the 'From Account' whitelist after previous tests.
182
+ */
140
183
describe ( 'addToWhitelist FromAccountWhitelist' , ( ) => {
141
- test ( 'it works ' , async ( ) => {
184
+ test ( 'should re-add an account address to FromAccountWhitelist successfully after removal ' , async ( ) => {
142
185
const res = await client . addToWhitelist ( {
143
186
PolicyUUID : POLICY_UUID ,
144
187
WhitelistType : WhitelistType . FromAccountWhitelist ,
145
188
Values : [ ACCOUNT_ADDRESS ] ,
146
189
} )
147
190
148
191
expect ( res ) . toEqual ( true )
149
- console . log ( res )
192
+ console . log ( 'Re-addition to FromAccountWhitelist response:' , res )
150
193
} )
151
194
} )
152
195
} )
0 commit comments