@ -2,21 +2,13 @@
import { render } from '@testing-library/react' ;
import { render } from '@testing-library/react' ;
import React from 'react' ;
import React from 'react' ;
import { SIZES , COLORS } from '../../../helpers/constants/design-system' ;
import { SIZES , COLORS } from '../../../helpers/constants/design-system' ;
import { ICON _NAMES } from './icon.constants' ;
import { Icon } from './icon' ;
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' , ( ) => {
describe ( 'Icon' , ( ) => {
it ( 'should render correctly' , ( ) => {
it ( 'should render correctly' , ( ) => {
const { getByTestId , container } = render (
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 ( getByTestId ( 'icon' ) ) . toBeDefined ( ) ;
expect ( container . querySelector ( 'svg' ) ) . toBeDefined ( ) ;
expect ( container . querySelector ( 'svg' ) ) . toBeDefined ( ) ;
@ -25,19 +17,16 @@ describe('Icon', () => {
const { getByTestId } = render (
const { getByTestId } = render (
< >
< >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
data - testid = "icon-add-square-filled"
data - testid = "icon-add-square-filled"
/ >
/ >
< Icon name = { ICON _NAMES . BANK _FILLED } data - testid = "icon-bank-filled" / >
< Icon
< Icon
name = { MOCK _ICON _NAMES . BANK _FILLED }
name = { ICON _NAMES . BOOKMARK _FILLED }
data - testid = "icon-bank-filled"
/ >
< Icon
name = { MOCK _ICON _NAMES . BOOKMARK _FILLED }
data - testid = "icon-bookmark-filled"
data - testid = "icon-bookmark-filled"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . CALCULATOR _FILLED }
name = { ICON _NAMES . CALCULATOR _FILLED }
data - testid = "icon-calculator-filled"
data - testid = "icon-calculator-filled"
/ >
/ >
< / > ,
< / > ,
@ -59,37 +48,37 @@ describe('Icon', () => {
const { getByTestId } = render (
const { getByTestId } = render (
< >
< >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . XXS }
size = { SIZES . XXS }
data - testid = "icon-xxs"
data - testid = "icon-xxs"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . XS }
size = { SIZES . XS }
data - testid = "icon-xs"
data - testid = "icon-xs"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . SM }
size = { SIZES . SM }
data - testid = "icon-sm"
data - testid = "icon-sm"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . MD }
size = { SIZES . MD }
data - testid = "icon-md"
data - testid = "icon-md"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . LG }
size = { SIZES . LG }
data - testid = "icon-lg"
data - testid = "icon-lg"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . XL }
size = { SIZES . XL }
data - testid = "icon-xl"
data - testid = "icon-xl"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
size = { SIZES . AUTO }
size = { SIZES . AUTO }
data - testid = "icon-auto"
data - testid = "icon-auto"
/ >
/ >
@ -107,17 +96,17 @@ describe('Icon', () => {
const { getByTestId } = render (
const { getByTestId } = render (
< >
< >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
color = { COLORS . ICON _DEFAULT }
color = { COLORS . ICON _DEFAULT }
data - testid = "icon-color-default"
data - testid = "icon-color-default"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
color = { COLORS . ICON _ALTERNATIVE }
color = { COLORS . ICON _ALTERNATIVE }
data - testid = "icon-color-alternative"
data - testid = "icon-color-alternative"
/ >
/ >
< Icon
< Icon
name = { MOCK _ ICON_NAMES . ADD _SQUARE _FILLED }
name = { ICON _NAMES . ADD _SQUARE _FILLED }
color = { COLORS . ICON _MUTED }
color = { COLORS . ICON _MUTED }
data - testid = "icon-color-muted"
data - testid = "icon-color-muted"
/ >
/ >