diff --git a/app/components/UI/FiatOnRampAggregator/Views/Quotes/Quotes.test.tsx b/app/components/UI/FiatOnRampAggregator/Views/Quotes/Quotes.test.tsx index 31a1a945bcf..2d3a39c42d3 100644 --- a/app/components/UI/FiatOnRampAggregator/Views/Quotes/Quotes.test.tsx +++ b/app/components/UI/FiatOnRampAggregator/Views/Quotes/Quotes.test.tsx @@ -5,12 +5,19 @@ import { QuoteError, QuoteResponse, } from '@consensys/on-ramp-sdk'; -import { act, fireEvent, screen } from '@testing-library/react-native'; +import { + act, + fireEvent, + screen, + render as renderComponent, +} from '@testing-library/react-native'; import { renderScreen } from '../../../../../util/test/renderWithProvider'; import Quotes, { QuotesParams } from './Quotes'; import { mockQuotesData } from './Quotes.constants'; import type { DeepPartial } from './Quotes.types'; +import Timer from './Timer'; +import LoadingQuotes from './LoadingQuotes'; import { OnRampSDK } from '../../sdk'; import useQuotes from '../../hooks/useQuotes'; @@ -525,3 +532,45 @@ describe('Quotes', () => { }); }); }); + +describe('LoadingQuotes component', () => { + it('renders correctly', () => { + renderComponent(); + expect(screen.toJSON()).toMatchSnapshot(); + }); +}); + +describe('Timer component', () => { + it.each` + isFetchingQuotes | pollingCyclesLeft | remainingTime + ${true} | ${1} | ${15000} + ${true} | ${1} | ${5000} + ${true} | ${0} | ${15000} + ${true} | ${0} | ${5000} + ${false} | ${1} | ${15000} + ${false} | ${1} | ${5000} + ${false} | ${0} | ${15000} + ${false} | ${0} | ${5000} + ${false} | ${0} | ${20000} + `( + 'renders correctly with isFetchingQuotes=$isFetchingQuotes, pollingCyclesLeft=$pollingCyclesLeft, remainingTime=$remainingTime', + ({ + isFetchingQuotes, + pollingCyclesLeft, + remainingTime, + }: { + isFetchingQuotes: boolean; + pollingCyclesLeft: number; + remainingTime: number; + }) => { + renderComponent( + , + ); + expect(screen.toJSON()).toMatchSnapshot(); + }, + ); +}); diff --git a/app/components/UI/FiatOnRampAggregator/Views/Quotes/__snapshots__/Quotes.test.tsx.snap b/app/components/UI/FiatOnRampAggregator/Views/Quotes/__snapshots__/Quotes.test.tsx.snap index 339dcbb3845..c65ffece468 100644 --- a/app/components/UI/FiatOnRampAggregator/Views/Quotes/__snapshots__/Quotes.test.tsx.snap +++ b/app/components/UI/FiatOnRampAggregator/Views/Quotes/__snapshots__/Quotes.test.tsx.snap @@ -1,5 +1,606 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`LoadingQuotes component renders correctly 1`] = ` +Array [ + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + , +] +`; + exports[`Quotes renders animation on first fetching 1`] = ` `; + +exports[`Timer component renders correctly with isFetchingQuotes=false, pollingCyclesLeft=0, remainingTime=5000 1`] = ` + + + Quotes expire in + + + 0:05 + + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=false, pollingCyclesLeft=0, remainingTime=15000 1`] = ` + + + Quotes expire in + + + 0:15 + + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=false, pollingCyclesLeft=0, remainingTime=20000 1`] = ` + + + Quotes expire in + + + 0:20 + + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=false, pollingCyclesLeft=1, remainingTime=5000 1`] = ` + + + New quotes in + + + 0:05 + + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=false, pollingCyclesLeft=1, remainingTime=15000 1`] = ` + + + New quotes in + + + 0:15 + + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=true, pollingCyclesLeft=0, remainingTime=5000 1`] = ` + + + + + Fetching new quotes... + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=true, pollingCyclesLeft=0, remainingTime=15000 1`] = ` + + + + + Fetching new quotes... + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=true, pollingCyclesLeft=1, remainingTime=5000 1`] = ` + + + + + Fetching new quotes... + + +`; + +exports[`Timer component renders correctly with isFetchingQuotes=true, pollingCyclesLeft=1, remainingTime=15000 1`] = ` + + + + + Fetching new quotes... + + +`;