|
| 1 | +import { |
| 2 | + getOnboardingCompletedAnalyticsProps, |
| 3 | + getOnboardingCompletedAnalyticsPropsFromSuccessFlow, |
| 4 | + getWalletSetupPropsFromSuccessFlow, |
| 5 | + normalizeOnboardingCompletedAccountType, |
| 6 | + OnboardingCompletedAccountType, |
| 7 | + ONBOARDING_IMPLEMENTATION_TYPE_NATIVE, |
| 8 | + ONBOARDING_TYPE_SEED_PHRASE, |
| 9 | + ONBOARDING_TYPE_SOCIAL_LOGIN, |
| 10 | +} from './onboardingCompletedAnalytics'; |
| 11 | +import { |
| 12 | + AccountType, |
| 13 | + ONBOARDING_SUCCESS_FLOW, |
| 14 | +} from '../../constants/onboarding'; |
| 15 | + |
| 16 | +describe('normalizeOnboardingCompletedAccountType', () => { |
| 17 | + it('maps social account types to schema account types', () => { |
| 18 | + expect(normalizeOnboardingCompletedAccountType('metamask_google')).toBe( |
| 19 | + OnboardingCompletedAccountType.Metamask, |
| 20 | + ); |
| 21 | + expect(normalizeOnboardingCompletedAccountType('imported_apple')).toBe( |
| 22 | + OnboardingCompletedAccountType.Imported, |
| 23 | + ); |
| 24 | + }); |
| 25 | + |
| 26 | + it('preserves hardware wallet account types', () => { |
| 27 | + expect(normalizeOnboardingCompletedAccountType('Ledger')).toBe( |
| 28 | + OnboardingCompletedAccountType.Ledger, |
| 29 | + ); |
| 30 | + expect(normalizeOnboardingCompletedAccountType('QR Hardware')).toBe( |
| 31 | + OnboardingCompletedAccountType.QrHardware, |
| 32 | + ); |
| 33 | + }); |
| 34 | +}); |
| 35 | + |
| 36 | +describe('getWalletSetupPropsFromSuccessFlow', () => { |
| 37 | + it('returns import props for seed phrase import flow', () => { |
| 38 | + expect( |
| 39 | + getWalletSetupPropsFromSuccessFlow( |
| 40 | + ONBOARDING_SUCCESS_FLOW.IMPORT_FROM_SEED_PHRASE, |
| 41 | + ), |
| 42 | + ).toEqual({ |
| 43 | + wallet_setup_type: 'import', |
| 44 | + new_wallet: false, |
| 45 | + isSocialLogin: false, |
| 46 | + }); |
| 47 | + }); |
| 48 | + |
| 49 | + it('returns social login props for seedless onboarding flow', () => { |
| 50 | + expect( |
| 51 | + getWalletSetupPropsFromSuccessFlow( |
| 52 | + ONBOARDING_SUCCESS_FLOW.SEEDLESS_ONBOARDING, |
| 53 | + ), |
| 54 | + ).toEqual({ |
| 55 | + wallet_setup_type: 'new', |
| 56 | + new_wallet: true, |
| 57 | + isSocialLogin: true, |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
| 61 | + |
| 62 | +describe('getOnboardingCompletedAnalyticsProps', () => { |
| 63 | + it('adds native implementation and seed phrase onboarding type', () => { |
| 64 | + expect( |
| 65 | + getOnboardingCompletedAnalyticsProps( |
| 66 | + { |
| 67 | + wallet_setup_type: 'new', |
| 68 | + new_wallet: true, |
| 69 | + account_type: AccountType.Metamask, |
| 70 | + is_basic_functionality_enabled: true, |
| 71 | + }, |
| 72 | + false, |
| 73 | + ), |
| 74 | + ).toEqual({ |
| 75 | + wallet_setup_type: 'new', |
| 76 | + new_wallet: true, |
| 77 | + account_type: OnboardingCompletedAccountType.Metamask, |
| 78 | + is_basic_functionality_enabled: true, |
| 79 | + implementation_type: ONBOARDING_IMPLEMENTATION_TYPE_NATIVE, |
| 80 | + onboarding_type: ONBOARDING_TYPE_SEED_PHRASE, |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + it('adds social login onboarding type when requested', () => { |
| 85 | + expect( |
| 86 | + getOnboardingCompletedAnalyticsProps( |
| 87 | + { |
| 88 | + wallet_setup_type: 'new', |
| 89 | + new_wallet: true, |
| 90 | + account_type: AccountType.MetamaskGoogle, |
| 91 | + }, |
| 92 | + true, |
| 93 | + ), |
| 94 | + ).toEqual({ |
| 95 | + wallet_setup_type: 'new', |
| 96 | + new_wallet: true, |
| 97 | + account_type: OnboardingCompletedAccountType.Metamask, |
| 98 | + implementation_type: ONBOARDING_IMPLEMENTATION_TYPE_NATIVE, |
| 99 | + onboarding_type: ONBOARDING_TYPE_SOCIAL_LOGIN, |
| 100 | + }); |
| 101 | + }); |
| 102 | +}); |
| 103 | + |
| 104 | +describe('getOnboardingCompletedAnalyticsPropsFromSuccessFlow', () => { |
| 105 | + it('builds import onboarding completed props', () => { |
| 106 | + expect( |
| 107 | + getOnboardingCompletedAnalyticsPropsFromSuccessFlow( |
| 108 | + ONBOARDING_SUCCESS_FLOW.IMPORT_FROM_SEED_PHRASE, |
| 109 | + { |
| 110 | + accountType: AccountType.Imported, |
| 111 | + isBasicFunctionalityEnabled: true, |
| 112 | + }, |
| 113 | + ), |
| 114 | + ).toEqual({ |
| 115 | + wallet_setup_type: 'import', |
| 116 | + new_wallet: false, |
| 117 | + account_type: OnboardingCompletedAccountType.Imported, |
| 118 | + is_basic_functionality_enabled: true, |
| 119 | + implementation_type: ONBOARDING_IMPLEMENTATION_TYPE_NATIVE, |
| 120 | + onboarding_type: ONBOARDING_TYPE_SEED_PHRASE, |
| 121 | + }); |
| 122 | + }); |
| 123 | +}); |
0 commit comments