Return

All tests / IndexedCounter index.tsx

100% Statements 12/12
100% Branches 0/0
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 392x 2x 2x 2x 2x 2x 2x             2x 3x 3x                                           2x  
import React from 'react';
import styles from './indexed.module.css';
import useIndexedPages from '@/hooks/useIndexedPages';
import RenderManager from '@/components/RenderManager';
import Tooltip from '@/components/Tooltip';
import { GiCheckboxTree } from 'react-icons/gi';
import { useIntl } from 'react-intl';
 
/**
 * @description This component is used to display the number of indexed pages on Google
 * @returns {JSX.Element}
 * @example <IndexedCounter />
 */
const IndexedCounter = () => {
    const { data, error, loading } = useIndexedPages();
    const { formatMessage: f } = useIntl();
 
    return (
        <Tooltip>
            <Tooltip.Trigger>
                <div className={styles.container} data-testid="indexed-counter">
                    <GiCheckboxTree className={styles.xrp} />
                    <RenderManager
                        error={error}
                        loading={loading}
                        errorTitle={f({ id: 'indexedCounter.error' })}
                        loadingTitle={f({ id: 'indexedCounter.loading' })}
                    >
                        <span>{data.num}</span>
                    </RenderManager>
                </div>
            </Tooltip.Trigger>
            <Tooltip.Content>{f({ id: 'indexedCounter.tooltip' }, { num: data.num })}</Tooltip.Content>
        </Tooltip>
    );
};
 
export default IndexedCounter;