1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 16:18:07 +01:00
metamask-extension/ui/components/app/srp-input/parse-secret-recovery-phrase'.test.js
Mark Stacey f49e5076f3
Refactor: Extract SRP input from create vault component (#13720)
This is a pure refactor that extracts the SRP input from the
`CreateNewVault` component. This is intended to make future changes to
the SRP input easier, and to reduce duplication between the old and new
onboarding flows.

Extensive unit tests have been added for the new SRP input component.

A new test library was added (`@testing-library/user-event`) for
simulating user events with components rendered using the
`@testing-library` library.

A new helper method has been added (`renderWithLocalization`) for
rendering components using `@testing-library` with just our
localization contexts added as a wrapper. The localization contexts
were already added by the `renderWithProviders` helper function, but
there is no need for a Redux provider in these unit tests.
2022-02-23 17:00:26 -03:30

41 lines
1.3 KiB
JavaScript

import { parseSecretRecoveryPhrase } from './parse-secret-recovery-phrase';
describe('parseSecretRecoveryPhrase', () => {
it('should handle a regular Secret Recovery Phrase', () => {
expect(parseSecretRecoveryPhrase('foo bar baz')).toStrictEqual(
'foo bar baz',
);
});
it('should handle a mixed-case Secret Recovery Phrase', () => {
expect(parseSecretRecoveryPhrase('FOO bAr baZ')).toStrictEqual(
'foo bar baz',
);
});
it('should handle an upper-case Secret Recovery Phrase', () => {
expect(parseSecretRecoveryPhrase('FOO BAR BAZ')).toStrictEqual(
'foo bar baz',
);
});
it('should trim extraneous whitespace from the given Secret Recovery Phrase', () => {
expect(parseSecretRecoveryPhrase(' foo bar baz ')).toStrictEqual(
'foo bar baz',
);
});
it('should return an empty string when given a whitespace-only string', () => {
expect(parseSecretRecoveryPhrase(' ')).toStrictEqual('');
});
it('should return an empty string when given a string with only symbols', () => {
expect(parseSecretRecoveryPhrase('$')).toStrictEqual('');
});
it('should return an empty string for both null and undefined', () => {
expect(parseSecretRecoveryPhrase(undefined)).toStrictEqual('');
expect(parseSecretRecoveryPhrase(null)).toStrictEqual('');
});
});