Skip to content

Commit

Permalink
test: fix CreditsAmount test
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi committed Sep 23, 2024
1 parent 681d9f7 commit 3348d62
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const CreditsWithForm = (args: any) => {
args.paymentOption === PAYMENT_OPTIONS.CARD
? { askDenom: CURRENCIES.usd, askBaseDenom: CURRENCIES.usd }
: defaultCryptoCurrency;
const [currency] = useState<Currency>(initCurrency);
const [spendingCap, setSpendingCap] = useState(0);
const [creditsAvailable, setCreditsAvailable] = useState(0);

Expand All @@ -52,6 +53,7 @@ const CreditsWithForm = (args: any) => {
<Form form={form as any} onSubmit={form.handleSubmit as any}>
<CreditsAmount
{...args}
currency={currency}
spendingCap={spendingCap}
setSpendingCap={setSpendingCap}
creditsAvailable={creditsAvailable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { cardSellOrders, cryptoCurrencies } from './CreditsAmount.mock';
describe('CreditsAmount', () => {
const formDefaultValues = {
paymentOption: PAYMENT_OPTIONS.CARD,
currency: { askDenom: CURRENCIES.usd, askBaseDenom: CURRENCIES.usd },
spendingCap: 3185,
setSpendingCap: () => {},
creditsAvailable: 1125,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { CreditsInput } from './CreditsInput';
import { CurrencyInput } from './CurrencyInput';

export const CreditsAmount = ({
currency,
paymentOption,
creditsAvailable,
setCreditsAvailable,
Expand All @@ -41,12 +42,7 @@ export const CreditsAmount = ({
creditTypePrecision,
}: CreditsAmountProps) => {
const [maxCreditsSelected, setMaxCreditsSelected] = useState(false);
const { setValue, trigger, control } =
useFormContext<ChooseCreditsFormSchemaType>();
const currency = useWatch({
control,
name: CURRENCY,
});
const { setValue, trigger } = useFormContext<ChooseCreditsFormSchemaType>();

const card = paymentOption === PAYMENT_OPTIONS.CARD;
const orderedSellOrders = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { UseStateSetter } from 'web-components/src/types/react/useState';

import { PaymentOptionsType } from 'pages/BuyCredits/BuyCredits.types';
import { UISellOrderInfo } from 'pages/Projects/AllProjects/AllProjects.types';
import { ChooseCreditsFormSchemaType } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema';

import { AllowedDenoms } from '../DenomLabel/DenomLabel.utils';

Expand All @@ -25,6 +24,7 @@ export interface CreditsAmountProps {
cryptoCurrencies: Currency[];
allowedDenoms?: AllowedDenoms;
creditTypePrecision?: number | null;
currency: Currency;
}

export interface CreditsInputProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export function ChooseCreditsForm({
cryptoCurrencies={cryptoCurrencies}
allowedDenoms={allowedDenoms}
creditTypePrecision={creditTypePrecision}
currency={currency}
/>
)}
{paymentOption === PAYMENT_OPTIONS.CRYPTO && (
Expand Down

0 comments on commit 3348d62

Please sign in to comment.