1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 22:24:27 +01:00
metamask-extension/ui/pages/first-time-flow/seed-phrase/seed-phrase.test.js
2022-08-16 10:25:30 -05:00

128 lines
3.1 KiB
JavaScript

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();
});
});