@nuskin/foundation-ui-components 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/src/common/card/CardButton.tsx +31 -0
  3. package/src/common/card/NsAwardCard.tsx +4 -2
  4. package/src/common/card/NsBrandCard.tsx +7 -17
  5. package/src/common/card/NsCheckoutCard.tsx +8 -7
  6. package/src/common/card/NsHeroCardLevel1.tsx +17 -35
  7. package/src/common/card/NsHeroCardLevel2.tsx +20 -46
  8. package/src/common/card/NsIconText.tsx +4 -4
  9. package/src/common/card/NsLargeCard.tsx +15 -47
  10. package/src/common/card/NsMediumCard.tsx +10 -21
  11. package/src/common/card/NsPost.tsx +5 -5
  12. package/src/common/card/NsSmallFullCard.tsx +10 -19
  13. package/src/common/card/NsXLargeCard.tsx +10 -9
  14. package/src/common/card/specs/NsAwardCard.spec.tsx +29 -0
  15. package/src/common/card/specs/NsBrandCard.spec.tsx +13 -26
  16. package/src/common/card/specs/NsCheckoutCard.spec.tsx +4 -15
  17. package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +16 -24
  18. package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +18 -20
  19. package/src/common/card/specs/NsIconText.spec.tsx +0 -3
  20. package/src/common/card/specs/NsLargeCard.spec.tsx +26 -19
  21. package/src/common/card/specs/NsMediumCard.spec.tsx +28 -12
  22. package/src/common/card/specs/NsPost.spec.tsx +8 -11
  23. package/src/common/card/specs/NsSmallFullCard.spec.tsx +23 -12
  24. package/src/common/card/specs/NsXLargeCard.spec.tsx +23 -11
  25. package/src/common/card/stories/NsAwardCard.stories.tsx +0 -3
  26. package/src/common/card/stories/NsBrandCard.stories.tsx +7 -3
  27. package/src/common/card/stories/NsCheckoutCard.stories.tsx +3 -4
  28. package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +10 -24
  29. package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +10 -29
  30. package/src/common/card/stories/NsIconText.stories.tsx +2 -20
  31. package/src/common/card/stories/NsLargeCard.stories.tsx +8 -7
  32. package/src/common/card/stories/NsMediumCard.stories.tsx +7 -6
  33. package/src/common/card/stories/NsPost.stories.tsx +2 -19
  34. package/src/common/card/stories/NsSmallFullCard.stories.tsx +7 -4
  35. package/src/common/card/stories/NsXLargeCard.stories.tsx +8 -4
  36. package/src/common/card/types.d.ts +12 -0
  37. package/src/common/carousal/RenderBrand.tsx +0 -1
@@ -1,13 +1,16 @@
1
1
  import Box from '@mui/material/Box';
2
2
  import { styled } from '@nuskin/foundation-theme';
3
- import { NsButton, NsImage } from '..';
3
+ import { NsImage } from '../';
4
+ import CardButton from './CardButton';
5
+ import { NsCardButton } from './types';
4
6
 
5
7
  type NsXLargeCardProps = {
6
8
  title: string;
7
9
  subtitle: string;
8
10
  backgroundImageUrl: string;
9
11
  backgroundImageAlt: string;
10
- cardLink: { href: string; title: string };
12
+ button?: NsCardButton;
13
+ className?: string;
11
14
  };
12
15
 
13
16
  const CardContainer = styled(Box)(() => {
@@ -50,9 +53,8 @@ const CardContainer = styled(Box)(() => {
50
53
  fontWeight: '400',
51
54
  marginTop: '20px',
52
55
  },
53
- '.action-link': {
56
+ '.cta': {
54
57
  marginTop: '20px',
55
- width: '70%',
56
58
  },
57
59
  };
58
60
  });
@@ -62,18 +64,17 @@ export default function NsXLargeCard({
62
64
  subtitle,
63
65
  backgroundImageUrl,
64
66
  backgroundImageAlt,
65
- cardLink,
67
+ button,
68
+ className,
66
69
  }: NsXLargeCardProps) {
67
70
  return (
68
- <CardContainer role="x-large-card" component="div" data-testid="x-large-card">
71
+ <CardContainer className={className} role="x-large-card" component="div" data-testid="x-large-card">
69
72
  <NsImage alt={backgroundImageAlt} src={backgroundImageUrl} className="image" />
70
73
  <div className="gradientOverlay"></div>
71
74
  <div className="content">
72
75
  <article className="subtitle">{subtitle}</article>
73
76
  <article className="title">{title}</article>
74
- <NsButton className="action-link" variant="outlined" color="secondary" href={cardLink.href}>
75
- {cardLink.title}
76
- </NsButton>
77
+ {button ? <CardButton {...button} /> : null}
77
78
  </div>
78
79
  </CardContainer>
79
80
  );
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import NsAwardCard from '../NsAwardCard';
4
+
5
+ describe('NsHeroCardLevel1 component', () => {
6
+ const props = {
7
+ title: 'AgeLoc LumiSpa iO',
8
+ awardName: '2023 Bronze Winner',
9
+ mediaOutlet: 'Edison Awards',
10
+ backgroundImageUrl: 'https://media.nuskin.com/m/2ec571a87dc9680c/Small-Edison-Bronze-Logo-Homepage.jpg',
11
+ backgroundImageAlt: 'Edison Bronze Logo',
12
+ };
13
+
14
+ it('1. renders with correct content and styles', () => {
15
+ render(<NsAwardCard {...props} />);
16
+
17
+ const awardCard = screen.getByTestId('award-card');
18
+ expect(awardCard).toBeInTheDocument();
19
+
20
+ const title = screen.queryByText('AgeLoc LumiSpa iO');
21
+ expect(title).toBeInTheDocument();
22
+
23
+ const awardName = screen.queryByText('2023 Bronze Winner');
24
+ expect(awardName).toBeInTheDocument();
25
+
26
+ const mediaOutlet = screen.queryByText('Edison Awards');
27
+ expect(mediaOutlet).toBeInTheDocument();
28
+ });
29
+ });
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
3
  import NsBrandCard from '../NsBrandCard';
5
4
 
6
5
  describe('NsBrandCard component', () => {
@@ -8,7 +7,13 @@ describe('NsBrandCard component', () => {
8
7
  title: 'ageLOC LumiSpa',
9
8
  backgroundImageUrl: 'https://media.nuskin.com/m/3604b5202b0b64c6/webimage-brand-lumispa-optweb.png',
10
9
  brandImageUrl: 'https://media.nuskin.com/m/2571a0407433a6e8/webimage-brand-lumispa.png',
11
- button: true,
10
+ button: {
11
+ showButton: true,
12
+ buttonText: 'Add to Cart',
13
+ buttonVariant: 'outlined' as 'outlined',
14
+ url: '#',
15
+ endIcon: 'cart' as 'cart',
16
+ },
12
17
  };
13
18
 
14
19
  it('1. renders with correct content and styles', () => {
@@ -39,33 +44,15 @@ describe('NsBrandCard component', () => {
39
44
  });
40
45
 
41
46
  it('4. does not render button when button prop is false', () => {
42
- const { container } = render(<NsBrandCard {...{ ...props, button: false }} />);
47
+ let updatedProps = { ...props };
48
+ updatedProps.button.showButton = false;
49
+ const { container } = render(<NsBrandCard {...updatedProps} />);
43
50
 
44
51
  const addToCartButton = container.querySelector('.cta');
45
52
  expect(addToCartButton).toBeNull();
46
53
  });
47
54
 
48
- it.skip('5. calls onClick when the "Add to Cart" button is clicked', () => {
49
- const onClickMock = jest.fn();
50
- render(<NsBrandCard {...props} onClick={onClickMock} />);
51
-
52
- const addToCartButton = screen.getByText('Add to Cart');
53
- userEvent.click(addToCartButton);
54
-
55
- expect(onClickMock).toHaveBeenCalled();
56
- });
57
-
58
- it('6. applies hover styles on mouseover', () => {
59
- render(<NsBrandCard {...props} />);
60
-
61
- const brandCard = screen.getByTestId('brand-card');
62
- userEvent.hover(brandCard);
63
-
64
- const brandTitle = screen.getByText('ageLOC LumiSpa');
65
- expect(brandTitle).toHaveStyle('opacity: 0.7');
66
- });
67
-
68
- it('7. renders with correct styles when size is "small"', () => {
55
+ it('5. renders with correct styles when size is "small"', () => {
69
56
  const { container } = render(<NsBrandCard {...props} size="small" />);
70
57
 
71
58
  const cardContainer = container.firstChild;
@@ -79,7 +66,7 @@ describe('NsBrandCard component', () => {
79
66
  `);
80
67
  });
81
68
 
82
- it('8. renders with correct styles when size is "large"', () => {
69
+ it('6. renders with correct styles when size is "large"', () => {
83
70
  render(<NsBrandCard {...props} size="large" />);
84
71
  const cardContainer = screen.getByTestId('brand-card') as HTMLElement;
85
72
  const computedStyles = window.getComputedStyle(cardContainer);
@@ -87,7 +74,7 @@ describe('NsBrandCard component', () => {
87
74
  expect(computedStyles.width).toBe('190px');
88
75
  });
89
76
 
90
- it('9. renders with default styles when size is not provided', () => {
77
+ it('7. renders with default styles when size is not provided', () => {
91
78
  render(<NsBrandCard {...props} />);
92
79
  const cardContainer = screen.getByTestId('brand-card') as HTMLElement;
93
80
  const computedStyles = window.getComputedStyle(cardContainer);
@@ -6,9 +6,10 @@ import NsCheckoutCard from '../NsCheckoutCard';
6
6
  describe('NsCheckoutCard component', () => {
7
7
  const props = {
8
8
  title: 'Section Title',
9
- address: 'Address',
10
9
  icon: 'home' as 'home',
11
- onClick: jest.fn(),
10
+ linkText: 'CHANGE',
11
+ url: '#',
12
+ className: '',
12
13
  };
13
14
 
14
15
  it('1. renders with correct content and styles', () => {
@@ -20,11 +21,8 @@ describe('NsCheckoutCard component', () => {
20
21
  const titleElement = screen.getByText(props.title);
21
22
  expect(titleElement).toBeInTheDocument();
22
23
 
23
- const addressElement = screen.getByText(props.address);
24
+ const addressElement = screen.getByText(props.linkText);
24
25
  expect(addressElement).toBeInTheDocument();
25
-
26
- const changeLink = screen.getByText('CHANGE');
27
- expect(changeLink).toBeInTheDocument();
28
26
  });
29
27
 
30
28
  it('2. toggles dropdown icon on click', () => {
@@ -38,13 +36,4 @@ describe('NsCheckoutCard component', () => {
38
36
  // fireEvent.click(dropdownIcon);
39
37
  // expect(dropdownIcon).toHaveAttribute('name', 'arrowDown');
40
38
  });
41
-
42
- it('3. calls onClick when the card is clicked', () => {
43
- render(<NsCheckoutCard {...props} />);
44
-
45
- const checkoutCard = screen.getByTestId('checkout-card');
46
- fireEvent.click(checkoutCard);
47
-
48
- expect(props.onClick).toHaveBeenCalled();
49
- });
50
39
  });
@@ -1,22 +1,21 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
3
  import NsHeroCardLevel1 from '../NsHeroCardLevel1';
5
4
 
6
5
  describe('NsHeroCardLevel1 component', () => {
7
6
  const props = {
8
- cardLink: {
9
- href: 'https://www.forceforgood.org/',
10
- title: 'SHOP NOW',
11
- },
12
- text: 'A skin ready for winter',
13
- body: 'We have brought these discoveries to life through our powerful skin care products and supplements.',
7
+ cardTitle: 'A skin ready for winter',
8
+ cardDescription:
9
+ 'We have brought these discoveries to life through our powerful skin care products and supplements.',
14
10
  backgroundImageUrl:
15
11
  'https://media.nuskin.com/m/9734240cc191163/webimage-lash-brow-serum-carousel-image-launch.png',
16
12
  backgroundImageAlt: 'lash brow serum carousel',
17
- onClick: jest.fn(),
18
- additionalProps: {
19
- testid: 'hero-card-level-1',
13
+ button: {
14
+ showButton: true,
15
+ buttonText: 'SHOP NOW',
16
+ buttonVariant: 'contained' as 'contained',
17
+ url: '#',
18
+ endIcon: 'home' as 'home',
20
19
  },
21
20
  };
22
21
 
@@ -26,23 +25,16 @@ describe('NsHeroCardLevel1 component', () => {
26
25
  const heroCard = screen.getByTestId('hero-card-level-1');
27
26
  expect(heroCard).toBeInTheDocument();
28
27
 
29
- const shopNowLink = screen.getByText('SHOP NOW');
28
+ const shopNowLink = screen.queryByText('SHOP NOW');
30
29
  expect(shopNowLink).toBeInTheDocument();
31
30
  });
32
31
 
33
- it.skip('2. calls onClick when the card is clicked', () => {
34
- render(<NsHeroCardLevel1 {...props} />);
32
+ it('2. does not render button when button prop is false', () => {
33
+ let updatedProps = { ...props };
34
+ updatedProps.button.showButton = false;
35
+ const { container } = render(<NsHeroCardLevel1 {...updatedProps} />);
35
36
 
36
- const heroCard = screen.getByTestId('hero-card-level-1');
37
- userEvent.click(heroCard);
38
-
39
- expect(props.onClick).toHaveBeenCalled();
40
- });
41
-
42
- it('3. applies hover styles on mouseover', () => {
43
- render(<NsHeroCardLevel1 {...props} />);
44
-
45
- const heroCard = screen.getByTestId('hero-card-level-1');
46
- userEvent.hover(heroCard);
37
+ const button = container.querySelector('.action-link');
38
+ expect(button).toBeNull();
47
39
  });
48
40
  });
@@ -1,24 +1,22 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
3
  import { NsHeroCardLevel2 } from '../';
5
4
 
6
5
  describe('NsHeroCardLevel2 component', () => {
7
6
  const props = {
8
- brand: 'Beauty focus™',
9
- text: 'Current shop deals',
10
- body: 'Lumispa, sunscreen and more',
11
- icon: 'home' as 'home',
12
- cardLink: {
13
- href: 'https://www.forceforgood.org/',
14
- title: 'Discover more',
15
- },
7
+ cardTitle: 'Current shop deals',
8
+ cardDescription: 'Lumispa, sunscreen and more',
9
+ brandName: 'Beauty focus™',
16
10
  backgroundImageUrl: 'https://media.nuskin.com/m/5f1c423bb57589f0/webimage-autumn-sale-carousel.png',
17
11
  backgroundImageAlt: 'lash brow serum carousel',
18
- additionalProps: {
19
- testid: 'hero-card-level-2',
12
+ button: {
13
+ showButton: true,
14
+ buttonText: 'Discover more',
15
+ buttonVariant: 'text' as 'text',
16
+ buttonColor: 'secondary' as 'secondary',
17
+ url: '#',
18
+ endIcon: 'home' as 'home',
20
19
  },
21
- onClick: jest.fn(),
22
20
  };
23
21
 
24
22
  it('1. renders with correct content and styles', () => {
@@ -36,16 +34,16 @@ describe('NsHeroCardLevel2 component', () => {
36
34
  const bodyContent = screen.getByText('Lumispa, sunscreen and more');
37
35
  expect(bodyContent).toBeInTheDocument();
38
36
 
39
- const discoverMoreLink = screen.getByRole('link', { name: 'Discover more' });
40
- expect(discoverMoreLink).toBeInTheDocument();
37
+ const button = screen.queryByText('Discover more');
38
+ expect(button).toBeInTheDocument();
41
39
  });
42
40
 
43
- it.skip('2. calls onClick when the card is clicked', () => {
44
- render(<NsHeroCardLevel2 {...props} />);
45
-
46
- const cardContainer = screen.getByTestId('hero-card-level-2');
47
- userEvent.click(cardContainer);
41
+ it('2. does not render button when button prop is false', () => {
42
+ let updatedProps = { ...props };
43
+ updatedProps.button.showButton = false;
44
+ render(<NsHeroCardLevel2 {...updatedProps} />);
48
45
 
49
- expect(props.onClick).toHaveBeenCalled();
46
+ const button = screen.queryByText('Discover more');
47
+ expect(button).not.toBeInTheDocument();
50
48
  });
51
49
  });
@@ -6,9 +6,6 @@ describe('NsIconText component', () => {
6
6
  const props = {
7
7
  text: 'Lorem ipsum',
8
8
  body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Natoque lacus, in amet nunc. ',
9
- additionalProps: {
10
- testid: 'icon-text-card',
11
- },
12
9
  };
13
10
 
14
11
  it('1. renders with correct content and styles', () => {
@@ -1,41 +1,48 @@
1
1
  import { render, screen } from '@testing-library/react';
2
- import userEvent from '@testing-library/user-event';
3
2
  import { NsLargeCard } from '../';
4
3
 
5
4
  describe('NsLargeCard component', () => {
6
5
  const props = {
7
- title: 'Title',
6
+ isHorizontal: false,
7
+ title: 'Personal Care',
8
8
  subtitle: 'Subtitle',
9
- intro: 'Introduction sentence',
10
- icon: 'cart' as 'cart',
11
- cardLink: {
12
- href: 'https://www.forceforgood.org/',
13
- title: 'Button Text',
9
+ intro: 'Nu Skin® product lines combine nature and science for skincare benefits you can see and feel.',
10
+ button: {
11
+ showButton: true,
12
+ buttonText: 'REVEAL YOUR BEST SKIN',
13
+ buttonVariant: 'outlined' as 'outlined',
14
+ buttonColor: 'secondary' as 'secondary',
15
+ url: 'https://www.forceforgood.org/',
14
16
  },
15
- backgroundImageUrl: 'https://example.com/image.jpg',
16
- backgroundImageAlt: 'Image Alt',
17
+ backgroundImageUrl:
18
+ 'https://media.nuskin.com/m/95f9cf4143e3882/Small-About_Us-Personal-Care-Products-Image.jpg',
19
+ backgroundImageAlt: 'Facial Moisturizers',
17
20
  };
18
21
 
19
22
  it('1. renders with correct content and styles', () => {
20
23
  render(<NsLargeCard {...props} />);
21
24
 
25
+ const button = screen.queryByText('REVEAL YOUR BEST SKIN');
26
+
22
27
  expect(screen.getByText(props.title)).toBeInTheDocument();
23
28
  expect(screen.getByText(props.subtitle)).toBeInTheDocument();
29
+ expect(screen.getByText(props.intro)).toBeInTheDocument();
30
+ expect(screen.getByText(props.intro)).toBeInTheDocument();
31
+ expect(button).toBeInTheDocument();
24
32
  });
25
33
 
26
- it('2. triggers the link when clicked', () => {
27
- render(<NsLargeCard {...props} />);
34
+ it('2. renders with flexDirection=row when isHorizontal is true', () => {
35
+ const { getByTestId } = render(<NsLargeCard {...{ ...props, isHorizontal: true }} />);
28
36
 
29
- userEvent.click(screen.getByRole('link'));
37
+ expect(getByTestId('large-card')).toHaveStyle('flex-direction: row');
30
38
  });
31
39
 
32
- it('3. renders NsLink and NsIcon when isHorizontal is true', () => {
33
- render(<NsLargeCard {...props} isHorizontal={true} />);
34
-
35
- const actionLink = screen.getByText(props.cardLink.title);
36
- expect(actionLink).toBeInTheDocument();
40
+ it('3. does not render button when button prop is false', () => {
41
+ let updatedProps = { ...props };
42
+ updatedProps.button.showButton = false;
43
+ const { container } = render(<NsLargeCard {...updatedProps} />);
37
44
 
38
- const parentDiv = actionLink.closest('.cta');
39
- expect(parentDiv).toBeInTheDocument();
45
+ const button = container.querySelector('.cta');
46
+ expect(button).toBeNull();
40
47
  });
41
48
  });
@@ -4,14 +4,19 @@ import NsMediumCard from '../NsMediumCard';
4
4
 
5
5
  describe('NsMediumCard component', () => {
6
6
  const props = {
7
- title: 'Sample Title',
8
- subtitle: 'Sample Subtitle',
9
- backgroundImageUrl: 'https://example.com/image.jpg',
10
- backgroundImageAlt: 'Sample Alt Text',
11
- cardLink: {
12
- href: 'https://www.example.com',
13
- title: 'Sample Link Text',
7
+ title: 'Sustainability',
8
+ titleFontWeight: 'bold' as 'bold',
9
+ subtitle:
10
+ 'We’re committed to keeping our global communities clean, safe, and protected for the future. We’re proud to embrace sustainable practices today for a resource-rich tomorrow.',
11
+ button: {
12
+ showButton: true,
13
+ buttonText: 'SEE WHAT WE’RE DOING',
14
+ buttonVariant: 'outlined' as 'outlined',
15
+ buttonColor: 'secondary' as 'secondary',
16
+ url: '#',
14
17
  },
18
+ backgroundImageUrl: 'https://media.nuskin.com/m/3353b9c05cb83860/Small-category-facial_moisturizers.jpg',
19
+ backgroundImageAlt: 'Lumi Spa',
15
20
  };
16
21
 
17
22
  it('1. renders with correct content and styles', () => {
@@ -20,16 +25,27 @@ describe('NsMediumCard component', () => {
20
25
  const mediumCard = screen.getByTestId('medium-card');
21
26
  expect(mediumCard).toBeInTheDocument();
22
27
 
23
- const titleElement = screen.getByText('Sample Title');
28
+ const titleElement = screen.getByText('Sustainability');
24
29
  expect(titleElement).toBeInTheDocument();
25
30
 
26
- const subtitleElement = screen.getByText('Sample Subtitle');
31
+ const subtitleElement = screen.getByText(
32
+ 'We’re committed to keeping our global communities clean, safe, and protected for the future. We’re proud to embrace sustainable practices today for a resource-rich tomorrow.'
33
+ );
27
34
  expect(subtitleElement).toBeInTheDocument();
28
35
 
29
- const imageElement = screen.getByAltText('Sample Alt Text');
36
+ const imageElement = screen.getByAltText('Lumi Spa');
30
37
  expect(imageElement).toBeInTheDocument();
31
38
 
32
- const linkElement = screen.getByText('Sample Link Text');
33
- expect(linkElement).toBeInTheDocument();
39
+ const button = screen.queryByText('SEE WHAT WE’RE DOING');
40
+ expect(button).toBeInTheDocument();
41
+ });
42
+
43
+ it('2. does not render button when button prop is false', () => {
44
+ let updatedProps = { ...props };
45
+ updatedProps.button.showButton = false;
46
+ const { container } = render(<NsMediumCard {...updatedProps} />);
47
+
48
+ const button = container.querySelector('.cta');
49
+ expect(button).toBeNull();
34
50
  });
35
51
  });
@@ -4,28 +4,25 @@ import NsPost from '../NsPost';
4
4
 
5
5
  describe('NsPost component', () => {
6
6
  const props = {
7
- text: 'Sample Text',
8
- body: 'Sample Body',
9
- backgroundImageUrl: 'https://example.com/image.jpg',
10
- backgroundImageAlt: 'Sample Alt Text',
11
- additionalProps: {
12
- testid: 'sample-post',
13
- },
7
+ text: '38 New Beauty Products Our Editors Are Loving',
8
+ body: 'SPA & BEAUTY TODAY',
9
+ backgroundImageUrl: 'https://media.nuskin.com/m/780f8d84bcb9d5ed/Small-Essence_News.jpg',
10
+ backgroundImageAlt: 'small essence news',
14
11
  };
15
12
 
16
13
  it('1. renders with correct content and styles', () => {
17
14
  render(<NsPost {...props} />);
18
15
 
19
- const postContainer = screen.getByTestId('sample-post');
16
+ const postContainer = screen.getByTestId('post-card');
20
17
  expect(postContainer).toBeInTheDocument();
21
18
 
22
- const textElement = screen.getByText('Sample Text');
19
+ const textElement = screen.getByText('38 New Beauty Products Our Editors Are Loving');
23
20
  expect(textElement).toBeInTheDocument();
24
21
 
25
- const bodyElement = screen.getByText('Sample Body');
22
+ const bodyElement = screen.getByText('SPA & BEAUTY TODAY');
26
23
  expect(bodyElement).toBeInTheDocument();
27
24
 
28
- const imageElement = screen.getByAltText('Sample Alt Text');
25
+ const imageElement = screen.getByAltText('small essence news');
29
26
  expect(imageElement).toBeInTheDocument();
30
27
  });
31
28
  });
@@ -4,13 +4,16 @@ import NsSmallFullCard from '../NsSmallFullCard';
4
4
 
5
5
  describe('NsSmallFullCard component', () => {
6
6
  const props = {
7
- title: 'Sample Title',
8
- subtitle: 'Sample Subtitle',
9
- backgroundImageUrl: 'https://example.com/image.jpg',
10
- backgroundImageAlt: 'Sample Alt Text',
11
- cardLink: {
12
- href: 'https://www.example.com',
13
- title: 'Button Text',
7
+ title: 'Title',
8
+ subtitle: 'Subtitle',
9
+ backgroundImageUrl: 'https://media.nuskin.com/m/4f5b0aee8fe3ff90/Small-category-makeup.jpg',
10
+ backgroundImageAlt: 'Facial Moisturizers',
11
+ button: {
12
+ showButton: true,
13
+ buttonText: 'Placeholder',
14
+ buttonVariant: 'outlined' as 'outlined',
15
+ buttonColor: 'secondary' as 'secondary',
16
+ url: '#',
14
17
  },
15
18
  };
16
19
 
@@ -20,17 +23,25 @@ describe('NsSmallFullCard component', () => {
20
23
  const cardContainer = screen.getByTestId('small-full-card');
21
24
  expect(cardContainer).toBeInTheDocument();
22
25
 
23
- const titleElement = screen.getByText('Sample Title');
26
+ const titleElement = screen.getByText('Title');
24
27
  expect(titleElement).toBeInTheDocument();
25
28
 
26
- const subtitleElement = screen.getByText('Sample Subtitle');
29
+ const subtitleElement = screen.getByText('Subtitle');
27
30
  expect(subtitleElement).toBeInTheDocument();
28
31
 
29
- const imageElement = screen.getByAltText('Sample Alt Text');
32
+ const imageElement = screen.getByAltText('Facial Moisturizers');
30
33
  expect(imageElement).toBeInTheDocument();
31
34
 
32
- const linkElement = screen.getByText('Button Text');
35
+ const linkElement = screen.getByText('Placeholder');
33
36
  expect(linkElement).toBeInTheDocument();
34
- expect(linkElement).toHaveAttribute('href', 'https://www.example.com');
37
+ });
38
+
39
+ it('2. does not render button when button prop is false', () => {
40
+ let updatedProps = { ...props };
41
+ updatedProps.button.showButton = false;
42
+ const { container } = render(<NsSmallFullCard {...updatedProps} />);
43
+
44
+ const button = container.querySelector('.cta');
45
+ expect(button).toBeNull();
35
46
  });
36
47
  });
@@ -4,13 +4,16 @@ import NsXLargeCard from '../NsXLargeCard';
4
4
 
5
5
  describe('NsXLargeCard component', () => {
6
6
  const props = {
7
- title: 'Sample Title',
8
- subtitle: 'Sample Subtitle',
9
- backgroundImageUrl: 'https://example.com/image.jpg',
10
- backgroundImageAlt: 'Sample Alt Text',
11
- cardLink: {
12
- href: 'https://www.example.com',
13
- title: 'Sample Link Text',
7
+ title: 'Title',
8
+ subtitle: 'Subtitle',
9
+ backgroundImageUrl: 'https://media.nuskin.com/m/4f5b0aee8fe3ff90/Small-category-makeup.jpg',
10
+ backgroundImageAlt: 'Facial Moisturizers',
11
+ button: {
12
+ showButton: true,
13
+ buttonText: 'Discover more',
14
+ buttonVariant: 'outlined' as 'outlined',
15
+ buttonColor: 'secondary' as 'secondary',
16
+ url: '#',
14
17
  },
15
18
  };
16
19
 
@@ -20,16 +23,25 @@ describe('NsXLargeCard component', () => {
20
23
  const xLargeCard = screen.getByTestId('x-large-card');
21
24
  expect(xLargeCard).toBeInTheDocument();
22
25
 
23
- const subtitleElement = screen.getByText('Sample Subtitle');
26
+ const subtitleElement = screen.getByText('Subtitle');
24
27
  expect(subtitleElement).toBeInTheDocument();
25
28
 
26
- const titleElement = screen.getByText('Sample Title');
29
+ const titleElement = screen.getByText('Title');
27
30
  expect(titleElement).toBeInTheDocument();
28
31
 
29
- const imageElement = screen.getByAltText('Sample Alt Text');
32
+ const imageElement = screen.getByAltText('Facial Moisturizers');
30
33
  expect(imageElement).toBeInTheDocument();
31
34
 
32
- const linkElement = screen.getByText('Sample Link Text');
35
+ const linkElement = screen.getByText('Discover more');
33
36
  expect(linkElement).toBeInTheDocument();
34
37
  });
38
+
39
+ it('2. does not render button when button prop is false', () => {
40
+ let updatedProps = { ...props };
41
+ updatedProps.button.showButton = false;
42
+ const { container } = render(<NsXLargeCard {...updatedProps} />);
43
+
44
+ const button = container.querySelector('.cta');
45
+ expect(button).toBeNull();
46
+ });
35
47
  });
@@ -1,5 +1,4 @@
1
1
  import type { StoryObj, Meta } from '@storybook/react';
2
- import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
2
  import { NsAwardCard } from '../';
4
3
 
5
4
  type ComponentType = typeof NsAwardCard;
@@ -9,8 +8,6 @@ type MetaStory = Meta<ComponentType>;
9
8
  export default {
10
9
  component: NsAwardCard,
11
10
  title: 'Components/Containers/Card/NsAwardCard',
12
- argTypes: {},
13
- decorators: [withCenterDecorator],
14
11
  } as MetaStory;
15
12
 
16
13
  const host = 'https://media.nuskin.com';
@@ -19,9 +19,13 @@ export const Default: Story = {
19
19
  backgroundImageUrl: 'https://media.nuskin.com/m/3604b5202b0b64c6/webimage-brand-lumispa-optweb.png',
20
20
  brandImageUrl: 'https://media.nuskin.com/m/2571a0407433a6e8/webimage-brand-lumispa.png',
21
21
  size: 'large',
22
- button: true,
23
- onClick: () => {
24
- console.log('onClick called');
22
+ button: {
23
+ showButton: true,
24
+ buttonText: 'Add to cart',
25
+ buttonVariant: 'outlined',
26
+ buttonColor: 'primary',
27
+ endIcon: 'cart',
28
+ url: '#',
25
29
  },
26
30
  },
27
31
  };