1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.test.js
Thomas Huang c162d52ca3
Various test files converting to @testing-library/react. (#15470)
* Convert Menu Bar test to tlr

* Add test ids to sig req footer buttons

* Convert Sig Req to tlr

* Convert First Time Flow Switch to tlr

* Convert Lock test to tlr

* Add test id to account options menu
2022-08-08 13:28:49 -07:00

124 lines
3.6 KiB
JavaScript

import configureMockStore from 'redux-mock-store';
import React from 'react';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import {
DEFAULT_ROUTE,
LOCK_ROUTE,
INITIALIZE_WELCOME_ROUTE,
INITIALIZE_UNLOCK_ROUTE,
INITIALIZE_END_OF_FLOW_ROUTE,
} from '../../../helpers/constants/routes';
import FirstTimeFlowSwitch from './first-time-flow-switch.container';
describe('FirstTimeFlowSwitch', () => {
it('redirects to /welcome route with null props', () => {
const mockState = {
metamask: {
completedOnboarding: null,
isInitialized: null,
isUnlocked: null,
seedPhraseBackedUp: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(INITIALIZE_WELCOME_ROUTE);
});
it('redirects to / route when completedOnboarding is true', () => {
const mockState = {
metamask: {
completedOnboarding: true,
isInitialized: null,
isUnlocked: null,
seedPhraseBackedUp: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(DEFAULT_ROUTE);
});
it('redirects to end of flow route when seedPhraseBackedUp is true', () => {
const mockState = {
metamask: {
completedOnboarding: false,
seedPhraseBackedUp: true,
isInitialized: null,
isUnlocked: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(
INITIALIZE_END_OF_FLOW_ROUTE,
);
});
it('redirects to end of flow route when seedPhraseBackedUp is false', () => {
const mockState = {
metamask: {
completedOnboarding: false,
seedPhraseBackedUp: false,
isInitialized: null,
isUnlocked: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(
INITIALIZE_END_OF_FLOW_ROUTE,
);
});
it('redirects to /lock route when isUnlocked is true', () => {
const mockState = {
metamask: {
completedOnboarding: false,
isUnlocked: true,
seedPhraseBackedUp: null,
isInitialized: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(LOCK_ROUTE);
});
it('redirects to /welcome route when isInitialized is false', () => {
const mockState = {
metamask: {
completedOnboarding: false,
isUnlocked: false,
isInitialized: false,
seedPhraseBackedUp: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(INITIALIZE_WELCOME_ROUTE);
});
it('redirects to /unlock route when isInitialized is true', () => {
const mockState = {
metamask: {
completedOnboarding: false,
isUnlocked: false,
isInitialized: true,
seedPhraseBackedUp: null,
},
};
const store = configureMockStore()(mockState);
const { history } = renderWithProvider(<FirstTimeFlowSwitch />, store);
expect(history.location.pathname).toStrictEqual(INITIALIZE_UNLOCK_ROUTE);
});
});