-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests to
immer
related modules
- Loading branch information
1 parent
719c02d
commit e110246
Showing
2 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...es/dapp-toolkit/src/modules/wallet-request/data-request/helpers/to-wallet-request.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { toWalletRequest } from './to-wallet-request' | ||
|
||
describe('toWalletRequest', () => { | ||
it('should transform data request to wallet request', () => { | ||
const testCases: [any, any][] = [ | ||
[ | ||
{ | ||
isConnect: true, | ||
oneTime: false, | ||
dataRequestState: {}, | ||
walletData: { | ||
accounts: [], | ||
personaData: [], | ||
proofs: [], | ||
}, | ||
}, | ||
{ | ||
auth: { | ||
discriminator: 'loginWithoutChallenge', | ||
}, | ||
discriminator: 'authorizedRequest', | ||
reset: { | ||
accounts: false, | ||
personaData: false, | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
isConnect: false, | ||
oneTime: true, | ||
challenge: 'abc', | ||
dataRequestState: { | ||
proofOfOwnership: {}, | ||
accounts: {}, | ||
}, | ||
walletData: { | ||
persona: {}, | ||
}, | ||
}, | ||
{ | ||
auth: { | ||
discriminator: 'loginWithoutChallenge', | ||
}, | ||
discriminator: 'authorizedRequest', | ||
oneTimeAccounts: { | ||
challenge: undefined, | ||
numberOfAccounts: { | ||
quantifier: 'atLeast', | ||
quantity: 1, | ||
}, | ||
}, | ||
proofOfOwnership: { | ||
challenge: 'abc', | ||
}, | ||
reset: { | ||
accounts: false, | ||
personaData: false, | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
isConnect: true, | ||
oneTime: false, | ||
challenge: 'abc', | ||
dataRequestState: { | ||
accounts: { | ||
withProof: true, | ||
}, | ||
personaData: { | ||
reset: true, | ||
}, | ||
persona: { | ||
withProof: true, | ||
}, | ||
}, | ||
walletData: { | ||
persona: {}, | ||
}, | ||
}, | ||
{ | ||
auth: { | ||
challenge: 'abc', | ||
discriminator: 'loginWithChallenge', | ||
}, | ||
discriminator: 'authorizedRequest', | ||
ongoingAccounts: { | ||
challenge: 'abc', | ||
numberOfAccounts: { | ||
quantifier: 'atLeast', | ||
quantity: 1, | ||
}, | ||
}, | ||
ongoingPersonaData: { | ||
isRequestingName: undefined, | ||
numberOfRequestedEmailAddresses: undefined, | ||
numberOfRequestedPhoneNumbers: undefined, | ||
}, | ||
reset: { | ||
accounts: false, | ||
personaData: false, | ||
}, | ||
}, | ||
], | ||
] | ||
|
||
testCases.forEach(([input, expected]) => { | ||
const result = toWalletRequest(input) | ||
expect(result.isOk() && result.value).toEqual(expected) | ||
}) | ||
}) | ||
}) |