• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / lace / 7826747364

08 Feb 2024 08:22AM UTC coverage: 53.785%. Remained the same
7826747364

push

github

web-flow
test(extension): updates for tests related to LW-9531 (#879)

1902 of 4443 branches covered (0.0%)

Branch coverage included in aggregate %.

4485 of 7432 relevant lines covered (60.35%)

53.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/browser-extension-wallet/src/features/delegation/components/Staking.tsx
1
import React from 'react';
×
2
import isNumber from 'lodash/isNumber';
×
3
import { useTranslation } from 'react-i18next';
×
4
import { Skeleton, Typography } from 'antd';
×
5
import { StakePoolSearch, StakePoolSearchProps, Wallet } from '@lace/cardano';
×
6
import { StakeFundsBanner } from '@views/browser/features/staking/components/StakeFundsBanner';
×
7
import { FundWalletBanner } from '@src/views/browser-view/components';
×
8
import { StakingInfo } from '@views/browser/features/staking/components/StakingInfo';
×
9
import { ExpandViewBanner } from './ExpandViewBanner';
×
10
import styles from './DelegationLayout.module.scss';
×
11
import { useWalletStore } from '@src/stores';
×
12

13
const { Text } = Typography;
×
14

15
export interface StakePool {
16
  id: string;
17
  theme?: string;
18
  name?: string;
19
  ticker?: string;
20
  logo?: string;
21
  pledgeMet?: boolean;
22
  retired?: boolean;
23
  onClick?: () => unknown;
24
}
25

26
export type StakingProps = {
27
  searchedPools: StakePoolSearchProps['pools'];
28
  currentStakePool?: StakePool;
29
  handleSearchChange: (val: string) => unknown;
30
  coinBalance: number;
31
  showAddFunds?: boolean;
32
  isSearching?: boolean;
33
  hasNoFunds?: boolean;
34
  isDelegating?: boolean;
35
  canDelegate?: boolean;
36
  walletAddress: Wallet.Cardano.PaymentAddress;
37
  fiat?: number;
38
  totalRewards: string;
39
  lastReward: string;
40
  onStakePoolSelect: () => void;
41
  onStakePoolClick?: (id: string) => void;
42
  cardanoCoin: Wallet.CoinId;
43
};
44

45
export const Staking = ({
×
46
  searchedPools,
47
  handleSearchChange,
48
  coinBalance,
49
  currentStakePool,
50
  fiat,
51
  isSearching,
52
  hasNoFunds,
53
  isDelegating,
54
  canDelegate,
55
  walletAddress,
56
  totalRewards,
57
  lastReward,
58
  onStakePoolSelect,
59
  onStakePoolClick,
60
  cardanoCoin
61
}: StakingProps): React.ReactElement => {
62
  const { t } = useTranslation();
×
63
  const totalResultCount = useWalletStore(({ stakePoolSearchResults }) => stakePoolSearchResults?.totalResultCount);
×
64
  const showExpandView = hasNoFunds || (!hasNoFunds && !isDelegating) || isDelegating;
×
65

66
  const stakePoolSearchTranslations = {
×
67
    gettingSaturated: t('cardano.stakePoolSearch.gettingSaturated'),
68
    saturated: t('cardano.stakePoolSearch.saturated'),
69
    overSaturation: t('cardano.stakePoolSearch.overSaturation'),
70
    staking: t('cardano.stakePoolSearch.staking'),
71
    searchPlaceholder: t('cardano.stakePoolSearch.searchPlaceholder')
72
  };
73

74
  return (
×
75
    <div className={styles.content}>
76
      <Skeleton loading={!isNumber(coinBalance)}>
77
        <div className={styles.contentWrapper}>
78
          {canDelegate && <StakeFundsBanner balance={coinBalance} popupView />}
×
79

80
          {hasNoFunds && (
×
81
            <FundWalletBanner
82
              title={t('browserView.assets.welcome')}
83
              subtitle={t('browserView.staking.fundWalletBanner.subtitle')}
84
              prompt={t('browserView.staking.fundWalletBanner.prompt')}
85
              walletAddress={walletAddress?.toString()}
×
86
              shouldHaveVerticalContent
87
            />
88
          )}
89
          {isDelegating && (
×
90
            <StakingInfo
91
              {...{
92
                ...currentStakePool,
93
                coinBalance,
94
                fiat,
95
                totalRewards,
96
                lastReward,
97
                cardanoCoin
98
              }}
99
              onStakePoolSelect={onStakePoolSelect}
100
              popupView
101
            />
102
          )}
103
          <div>
104
            <div className={styles.title}>
105
              <h1 className={styles.subHeader}>{t('staking.stakePools.sectionTitle')}</h1>
106
              <Text data-testid="section-title-counter" className={styles.sideText}>
107
                ({totalResultCount || 0})
×
108
              </Text>
109
            </div>
110

111
            <StakePoolSearch
112
              // eslint-disable-next-line unicorn/no-null
113
              value={null}
114
              pools={searchedPools}
115
              onChange={handleSearchChange}
116
              isSearching={isSearching}
117
              onStakePoolClick={onStakePoolClick}
118
              translations={stakePoolSearchTranslations}
119
              withSuggestions
120
            />
121
          </div>
122
          {showExpandView && <ExpandViewBanner />}
×
123
        </div>
124
      </Skeleton>
125
    </div>
126
  );
127
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc