-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding static icon names to test env file #16078
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
process.env.METAMASK_ENV = 'test'; | ||
|
||
/** | ||
* Used for testing components that use the Icon component | ||
* 'ui/components/component-library/icon/icon.js' | ||
*/ | ||
process.env.ICON_NAMES = { | ||
LOADING_FILLED: 'loading-filled', | ||
CLOSE_OUTLINE: 'close-outline', | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are now taken care of by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// jest specific env vars that break mocha tests | ||
import { generateIconNames } from '../../development/generate-icon-names'; | ||
|
||
/** | ||
* Used for testing components that use the Icon component | ||
* 'ui/components/component-library/icon/icon.js' | ||
*/ | ||
|
||
process.env.ICON_NAMES = generateIconNames(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,13 @@ | |
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { SIZES, COLORS } from '../../../helpers/constants/design-system'; | ||
import { ICON_NAMES } from './icon.constants'; | ||
import { Icon } from './icon'; | ||
|
||
// Icon names are stored in the ICON_NAMES environment variable | ||
// mocking the environment variable here | ||
const MOCK_ICON_NAMES = { | ||
ADD_SQUARE_FILLED: 'add-square-filled', | ||
BANK_FILLED: 'bank-filled', | ||
BOOKMARK_FILLED: 'bookmark-filled', | ||
CALCULATOR_FILLED: 'calculator-filled', | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer need to mock the icon names env var because we are setting it in |
||
describe('Icon', () => { | ||
it('should render correctly', () => { | ||
const { getByTestId, container } = render( | ||
<Icon name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} data-testid="icon" />, | ||
<Icon name={ICON_NAMES.ADD_SQUARE_FILLED} data-testid="icon" />, | ||
); | ||
expect(getByTestId('icon')).toBeDefined(); | ||
expect(container.querySelector('svg')).toBeDefined(); | ||
|
@@ -25,19 +17,16 @@ describe('Icon', () => { | |
const { getByTestId } = render( | ||
<> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
data-testid="icon-add-square-filled" | ||
/> | ||
<Icon name={ICON_NAMES.BANK_FILLED} data-testid="icon-bank-filled" /> | ||
<Icon | ||
name={MOCK_ICON_NAMES.BANK_FILLED} | ||
data-testid="icon-bank-filled" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.BOOKMARK_FILLED} | ||
name={ICON_NAMES.BOOKMARK_FILLED} | ||
data-testid="icon-bookmark-filled" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.CALCULATOR_FILLED} | ||
name={ICON_NAMES.CALCULATOR_FILLED} | ||
data-testid="icon-calculator-filled" | ||
/> | ||
</>, | ||
|
@@ -59,37 +48,37 @@ describe('Icon', () => { | |
const { getByTestId } = render( | ||
<> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.XXS} | ||
data-testid="icon-xxs" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.XS} | ||
data-testid="icon-xs" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.SM} | ||
data-testid="icon-sm" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.MD} | ||
data-testid="icon-md" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.LG} | ||
data-testid="icon-lg" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.XL} | ||
data-testid="icon-xl" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
size={SIZES.AUTO} | ||
data-testid="icon-auto" | ||
/> | ||
|
@@ -107,17 +96,17 @@ describe('Icon', () => { | |
const { getByTestId } = render( | ||
<> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
color={COLORS.ICON_DEFAULT} | ||
data-testid="icon-color-default" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
color={COLORS.ICON_ALTERNATIVE} | ||
data-testid="icon-color-alternative" | ||
/> | ||
<Icon | ||
name={MOCK_ICON_NAMES.ADD_SQUARE_FILLED} | ||
name={ICON_NAMES.ADD_SQUARE_FILLED} | ||
color={COLORS.ICON_MUTED} | ||
data-testid="icon-color-muted" | ||
/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ exports[`PickerNetwork should render the label inside the PickerNetwork 1`] = ` | |
</p> | ||
<div | ||
class="box mm-picker-network__arrow-down-icon icon icon--size-xs box--flex-direction-row box--color-icon-default" | ||
style="mask-image: url('./images/icons/icon-undefined.svg;" | ||
style="mask-image: url('./images/icons/icon-arrow-down.svg;" | ||
/> | ||
</button> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having to update snapshots means that it's working! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still need to get the url formatting fixed
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! It will be apart of the house keeping ticket |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating
generateIconNames
to be synchronous because the genius that is @Gudahtt somehow figured out that to get it to work with jest