@ -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' ,
} ;
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"
/ >