Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyjosh committed Feb 16, 2025
1 parent af635ee commit abdfe64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ describe('getDeploymentTransactionArgs', () => {

describe('successful cases', () => {
it('should successfully return deployment transaction args', async () => {
mockGui.generateApprovalCalldatas = vi.fn().mockResolvedValue({
Calldatas: [{ token: '0x123', amount: '1000' }]
});
const result = await getDeploymentTransactionArgs(mockGui, mockWagmiConfig, mockTokenOutputs);

expect(result).toEqual({
Expand Down Expand Up @@ -162,6 +165,10 @@ describe('getDeploymentTransactionArgs', () => {
symbol: 'TEST'
});

mockGui.generateApprovalCalldatas = vi.fn().mockResolvedValue({
Calldatas: [{ token: '0x123', amount: '1000' }]
});

await expect(
getDeploymentTransactionArgs(mockGui, mockWagmiConfig, mockTokenOutputs)
).rejects.toThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function getDeploymentTransactionArgs(
})
);

if (approvalResults != 'NoDeposits') {
if (approvalResults !== 'NoDeposits') {
approvals = approvalResults.Calldatas.map((approval) => {
const token = outputTokenInfos.find((token) => token?.address === approval.token);
if (!token) {
Expand All @@ -99,6 +99,8 @@ export async function getDeploymentTransactionArgs(
});
}
} catch (error) {
console.log('alltokenoutputs', allTokenOutputs);
console.log('approvalresults', approvalResults);
throw new Error(
`${AddOrderErrors.TOKEN_INFO_FAILED}: ${error instanceof Error ? error.message : 'Unknown error'}`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-components/src/lib/types/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ExtendedApprovalCalldata } from '$lib/stores/transactionStore';
import type { DepositAndAddOrderCalldataResult } from '@rainlanguage/orderbook/js_api';
import type { ApprovalCalldataResult } from '@rainlanguage/orderbook/js_api';
import type { Hex } from 'viem';

export type DeploymentArgs = {
approvals: ApprovalCalldataResult;
approvals: ExtendedApprovalCalldata[];
deploymentCalldata: DepositAndAddOrderCalldataResult;
orderbookAddress: Hex;
chainId: number;
Expand Down

0 comments on commit abdfe64

Please sign in to comment.