Skip to content

Commit

Permalink
Unit test proptype (MetaMask#14868)
Browse files Browse the repository at this point in the history
* Add missing props to advanced tab component test.

* Add icon size prop to site icon test

* Add hardwareWalletRequiresConnection prop to signature request test as a boolean

* Add setShowDetectedTokens prop to detect token test

* Set Setting description prop to be either object or string.
  • Loading branch information
tmashuang committed Jun 7, 2022
1 parent ae76c36 commit 18e4af7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ui/components/app/detected-token/detected-token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import DetectedToken from './detected-token';
describe('DetectedToken', () => {
it('should render the detected token found page', async () => {
const store = configureStore(testData);
renderWithProvider(<DetectedToken />, store);
const props = {
setShowDetectedTokens: jest.fn(),
};

renderWithProvider(<DetectedToken {...props} />, store);

expect(screen.getByText('0 LINK')).toBeInTheDocument();
expect(screen.getByText('0 COMP')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Signature Request Component', () => {
};
const wrapper = shallowWithContext(
<SignatureRequest
hardwareWalletRequiresConnection={() => false}
hardwareWalletRequiresConnection={false}
clearConfirmTransaction={() => undefined}
cancel={() => undefined}
sign={() => undefined}
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('Signature Request Component', () => {
};
const wrapper = shallowWithContext(
<SignatureRequest
hardwareWalletRequiresConnection={() => false}
hardwareWalletRequiresConnection={false}
clearConfirmTransaction={() => undefined}
cancel={() => undefined}
sign={() => undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('Signature Request', () => {
history: {
push: sinon.spy(),
},
hardwareWalletRequiresConnection: false,
clearConfirmTransaction: sinon.spy(),
cancelMessage: sinon.spy(),
cancel: sinon.stub().resolves(),
Expand Down
3 changes: 2 additions & 1 deletion ui/components/ui/site-icon/site-icon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import SiteIcon from '.';

describe('SiteIcon', () => {
const args = {
size: 32,
name: 'Snap name',
icon: './images/eth_logo.svg',
className: 'classname-test',
fallbackClassName: 'fallback-classname-test',
};

it('should render without crashing', () => {
const { getByText } = render(<SiteIcon name={args.name} />);
const { getByText } = render(<SiteIcon size={32} name={args.name} />);
expect(getByText('S')).toBeDefined();
});

Expand Down
2 changes: 1 addition & 1 deletion ui/pages/onboarding-flow/privacy-settings/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Setting.propTypes = {
value: PropTypes.bool,
setValue: PropTypes.func,
title: PropTypes.string,
description: PropTypes.string,
description: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
};
6 changes: 6 additions & 0 deletions ui/pages/settings/advanced-tab/advanced-tab.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('AdvancedTab Component', () => {
dismissSeedBackUpReminder={false}
useTokenDetection
setUseTokenDetection={toggleTokenDetection}
userHasALedgerAccount
/>,
{
context: {
Expand Down Expand Up @@ -59,6 +60,9 @@ describe('AdvancedTab Component', () => {
setDismissSeedBackUpReminder={() => undefined}
dismissSeedBackUpReminder={false}
setShowTestNetworks={toggleTestnet}
useTokenDetection
setUseTokenDetection={toggleTokenDetection}
userHasALedgerAccount
/>,
{
context: {
Expand Down Expand Up @@ -103,6 +107,7 @@ describe('AdvancedTab Component', () => {
dismissSeedBackUpReminder={false}
useTokenDetection
setUseTokenDetection={toggleTokenDetection}
userHasALedgerAccount
/>,
{
context: {
Expand Down Expand Up @@ -139,6 +144,7 @@ describe('AdvancedTab Component', () => {
dismissSeedBackUpReminder={false}
useTokenDetection
setUseTokenDetection={toggleTokenDetection}
userHasALedgerAccount
/>,
{
context: {
Expand Down

0 comments on commit 18e4af7

Please sign in to comment.