You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tag:
Branch:
Tree:
4016bb535b
develop
feature/default_network_editable
v10.22.3
${ noResults }
100 lines
2.7 KiB
100 lines
2.7 KiB
import React from 'react';
|
|||
import { shallow } from 'enzyme';
|
|||
import sinon from 'sinon';
|
|||
import ImportWithSeedPhrase from './import-with-seed-phrase.component';
|
|||
|
|||
|
function shallowRender(props = {}, context = {}) {
|
||
return shallow(<ImportWithSeedPhrase {...props} />, {
|
|||
context: {
|
|||
t: (str) => `${str}_t`,
|
|||
metricsEvent: sinon.spy(),
|
|||
...context,
|
|||
},
|
|||
});
|
|||
}
|
|||
|
|||
describe('ImportWithSeedPhrase Component', () => {
|
|||
it('should render without error', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
const textareaCount = root.find('.first-time-flow__textarea').length;
|
|||
expect(textareaCount).toStrictEqual(1);
|
|||
});
|
|||
|
|||
describe('parseSeedPhrase', () => {
|
|||
it('should handle a regular seed phrase', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase('foo bar baz')).toStrictEqual('foo bar baz');
|
|||
});
|
|||
|
|||
it('should handle a mixed-case seed phrase', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase('FOO bAr baZ')).toStrictEqual('foo bar baz');
|
|||
});
|
|||
|
|||
it('should handle an upper-case seed phrase', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase('FOO BAR BAZ')).toStrictEqual('foo bar baz');
|
|||
});
|
|||
|
|||
it('should trim extraneous whitespace from the given seed phrase', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase(' foo bar baz ')).toStrictEqual(
|
|||
|
'foo bar baz',
|
||
);
|
|||
});
|
|||
|
|||
it('should return an empty string when given a whitespace-only string', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase(' ')).toStrictEqual('');
|
|||
});
|
|||
|
|||
it('should return an empty string when given a string with only symbols', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase('$')).toStrictEqual('');
|
|||
});
|
|||
|
|||
it('should return an empty string for both null and undefined', () => {
|
|||
const root = shallowRender({
|
|||
onSubmit: sinon.spy(),
|
|||
});
|
|||
|
|||
const { parseSeedPhrase } = root.instance();
|
|||
|
|||
expect(parseSeedPhrase(undefined)).toStrictEqual('');
|
|||
expect(parseSeedPhrase(null)).toStrictEqual('');
|
|||
});
|
|||
});
|
|||
});
|