1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 15:35:46 +01:00
metamask-extension/ui/pages/first-time-flow/seed-phrase/seed-phrase.test.js

128 lines
3.1 KiB
JavaScript
Raw Normal View History

2022-08-16 17:25:30 +02:00
import React from 'react';
import sinon from 'sinon';
import configureMockStore from 'redux-mock-store';
import { screen } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import {
INITIALIZE_SEED_PHRASE_ROUTE,
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
INITIALIZE_SEED_PHRASE_INTRO_ROUTE,
} from '../../../helpers/constants/routes';
import SeedPhrase from '.';
describe('SeedPhrase Component', () => {
afterEach(() => {
sinon.restore();
});
it('should match snapshot', () => {
const props = {
history: {
push: sinon.stub(),
},
verifySeedPhrase: sinon.stub().resolves('verifed seed'),
};
const { container } = renderWithProvider(<SeedPhrase {...props} />);
expect(container).toMatchSnapshot();
});
it('should render confirm seed phrase component with seed-phrase/confirm route', () => {
const mockState = {
metamask: {},
};
const store = configureMockStore()(mockState);
const props = {
history: {
push: sinon.stub(),
},
verifySeedPhrase: sinon.stub().resolves(),
};
renderWithProvider(
<SeedPhrase {...props} />,
store,
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
);
const confirmSeedPhrase = screen.queryByTestId('confirm-seed-phrase');
expect(confirmSeedPhrase).toBeInTheDocument();
});
it('should render reveal-seed-phrase component with /seed-phrase route', () => {
const mockState = {
metamask: {},
};
const store = configureMockStore()(mockState);
const props = {
history: {
push: sinon.stub(),
},
verifySeedPhrase: sinon.stub().resolves(),
};
renderWithProvider(
<SeedPhrase {...props} />,
store,
INITIALIZE_SEED_PHRASE_ROUTE,
);
const confirmSeedPhrase = screen.queryByTestId('reveal-seed-phrase');
expect(confirmSeedPhrase).toBeInTheDocument();
});
it('should render reveal-seed-phrase component with /backup-seed-phrase route', () => {
const mockState = {
metamask: {
onboardingTabs: [],
},
};
const store = configureMockStore()(mockState);
const props = {
history: {
push: sinon.stub(),
},
verifySeedPhrase: sinon.stub().resolves(),
};
renderWithProvider(
<SeedPhrase {...props} />,
store,
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
);
const confirmSeedPhrase = screen.queryByTestId('reveal-seed-phrase');
expect(confirmSeedPhrase).toBeInTheDocument();
});
it('should render reveal-seed-phrase component with /seed-phrase-intro route', () => {
const mockState = {
metamask: {
onboardingTabs: [],
},
};
const store = configureMockStore()(mockState);
const props = {
history: {
push: sinon.stub(),
},
verifySeedPhrase: sinon.stub().resolves(),
};
renderWithProvider(
<SeedPhrase {...props} />,
store,
INITIALIZE_SEED_PHRASE_INTRO_ROUTE,
);
const seedPhraseIntro = screen.queryByTestId('seed-phrase-intro');
expect(seedPhraseIntro).toBeInTheDocument();
});
});