Skip to content

Commit 3b750d0

Browse files
authored
test: add account rekey component test (#62)
1 parent edb2b55 commit 3b750d0

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

src/features/accounts/pages/account-page.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
accountApplicationsOptedInLabel,
2020
accountAssetsOptedInLabel,
2121
accountActivityLabel,
22+
accountRekeyedToLabel,
2223
} from '../components/labels'
2324
import { assetResultsAtom } from '@/features/assets/data'
2425
import { assetResultMother } from '@/tests/object-mother/asset-result'
@@ -139,4 +140,40 @@ describe('account-page', () => {
139140
)
140141
})
141142
})
143+
describe('when rendering an account with rekey', () => {
144+
const accountResult = accountResultMother['mainnet-DGOANM6JL4VNSBJW737T24V4WVQINFWELRE3OKHQQFZ2JFMVKUF52D4AY4']().build()
145+
146+
it('should be rendered with the correct data', () => {
147+
const myStore = createStore()
148+
myStore.set(accountResultsAtom, new Map([[accountResult.address, atom(accountResult)]]))
149+
150+
vi.mocked(useParams).mockImplementation(() => ({ address: accountResult.address }))
151+
152+
return executeComponentTest(
153+
() => render(<AccountPage />, undefined, myStore),
154+
async (component) => {
155+
await waitFor(() => {
156+
const informationCard = component.getByLabelText(accountInformationLabel)
157+
descriptionListAssertion({
158+
container: informationCard,
159+
items: [
160+
{ term: accountAddressLabel, description: 'DGOANM6JL4VNSBJW737T24V4WVQINFWELRE3OKHQQFZ2JFMVKUF52D4AY4' },
161+
{ term: accountBalanceLabel, description: '98.433606' },
162+
{ term: accountMinBalanceLabel, description: '2.2285' },
163+
{ term: accountAssetsHeldLabel, description: '0' },
164+
{ term: accountAssetsCreatedLabel, description: '0' },
165+
{ term: accountAssetsOptedInLabel, description: '0' },
166+
{ term: accountApplicationsCreatedLabel, description: '0' },
167+
{ term: accountApplicationsOptedInLabel, description: '8' },
168+
{ term: accountRekeyedToLabel, description: 'K7F3GQNOXIMJFF2NJSBHZ7OPNWVLIJM3BN6CYAZJBY3MS6C7TN24JTYX5E' },
169+
],
170+
})
171+
const activityTabList = component.getByRole('tablist', { name: accountActivityLabel })
172+
expect(activityTabList).toBeTruthy()
173+
expect(activityTabList.children.length).toBe(7)
174+
})
175+
}
176+
)
177+
})
178+
})
142179
})

src/tests/object-mother/account-result.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,89 @@ export const accountResultMother = {
173173
'total-created-assets': 1,
174174
} satisfies AccountResult)
175175
},
176+
177+
['mainnet-DGOANM6JL4VNSBJW737T24V4WVQINFWELRE3OKHQQFZ2JFMVKUF52D4AY4']: () => {
178+
return new AccountResultBuilder({
179+
address: 'DGOANM6JL4VNSBJW737T24V4WVQINFWELRE3OKHQQFZ2JFMVKUF52D4AY4',
180+
amount: 98433606,
181+
'amount-without-pending-rewards': 98433606,
182+
'apps-local-state': [
183+
{
184+
id: 811554792,
185+
schema: {
186+
'num-byte-slice': 0,
187+
'num-uint': 0,
188+
},
189+
},
190+
{
191+
id: 811555774,
192+
schema: {
193+
'num-byte-slice': 0,
194+
'num-uint': 0,
195+
},
196+
},
197+
{
198+
id: 811556459,
199+
schema: {
200+
'num-byte-slice': 0,
201+
'num-uint': 0,
202+
},
203+
},
204+
{
205+
id: 811563899,
206+
schema: {
207+
'num-byte-slice': 0,
208+
'num-uint': 0,
209+
},
210+
},
211+
{
212+
id: 811564745,
213+
schema: {
214+
'num-byte-slice': 0,
215+
'num-uint': 0,
216+
},
217+
},
218+
{
219+
id: 811565811,
220+
schema: {
221+
'num-byte-slice': 0,
222+
'num-uint': 0,
223+
},
224+
},
225+
{
226+
id: 812246978,
227+
schema: {
228+
'num-byte-slice': 0,
229+
'num-uint': 0,
230+
},
231+
},
232+
{
233+
id: 829144306,
234+
'key-value': [],
235+
schema: {
236+
'num-byte-slice': 0,
237+
'num-uint': 1,
238+
},
239+
},
240+
],
241+
'apps-total-schema': {
242+
'num-byte-slice': 0,
243+
'num-uint': 1,
244+
},
245+
assets: [],
246+
'auth-addr': 'K7F3GQNOXIMJFF2NJSBHZ7OPNWVLIJM3BN6CYAZJBY3MS6C7TN24JTYX5E',
247+
'created-apps': [],
248+
'created-assets': [],
249+
'min-balance': 2228500,
250+
'pending-rewards': 0,
251+
'reward-base': 218288,
252+
rewards: 0,
253+
round: 39090114,
254+
status: AccountStatus.Offline,
255+
'total-apps-opted-in': 8,
256+
'total-assets-opted-in': 0,
257+
'total-created-apps': 0,
258+
'total-created-assets': 0,
259+
})
260+
},
176261
}

0 commit comments

Comments
 (0)