@times-components/ts-components 1.145.1-cfea81c4084e6f91221ea00fec9fc730d5b933cb.4 → 1.145.1-e871182934034874ea6a75e1e684090e5504df44.2
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.
- package/dist/components/travel-mini-cta/index.d.ts +3 -0
- package/dist/components/travel-mini-cta/index.js +86 -0
- package/dist/components/travel-mini-cta/styles.d.ts +42 -0
- package/dist/components/travel-mini-cta/styles.js +273 -0
- package/dist/components/travel-mini-cta/travel-mini-cta.stories.d.ts +110 -0
- package/dist/components/travel-mini-cta/travel-mini-cta.stories.js +121 -0
- package/dist/components/travel-mini-cta/types.d.ts +10 -0
- package/dist/components/{trip-cards → travel-mini-cta}/types.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/utils/applyDarkMode.d.ts +1 -0
- package/dist/utils/applyDarkMode.js +12 -0
- package/dist/utils/getMediaQuery.d.ts +11 -0
- package/dist/utils/getMediaQuery.js +19 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/package.json +3 -3
- package/rnw.js +1 -1
- package/src/components/travel-mini-cta/index.tsx +164 -0
- package/src/components/travel-mini-cta/styles.ts +336 -0
- package/src/components/travel-mini-cta/travel-mini-cta.stories.tsx +157 -0
- package/src/components/travel-mini-cta/types.ts +10 -0
- package/src/index.ts +1 -2
- package/src/utils/applyDarkMode.ts +12 -0
- package/src/utils/getMediaQuery.ts +25 -0
- package/src/utils/index.ts +2 -0
- package/dist/components/carousel-component/CarouselComponent.stories.d.ts +0 -1
- package/dist/components/carousel-component/CarouselComponent.stories.js +0 -146
- package/dist/components/carousel-component/CarouselItem.d.ts +0 -3
- package/dist/components/carousel-component/CarouselItem.js +0 -11
- package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +0 -8
- package/dist/components/carousel-component/DefaultNavigationArrow.js +0 -6
- package/dist/components/carousel-component/DefaultPageDot.d.ts +0 -8
- package/dist/components/carousel-component/DefaultPageDot.js +0 -4
- package/dist/components/carousel-component/__tests__/CarouselComponent.test.d.ts +0 -1
- package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +0 -163
- package/dist/components/carousel-component/__tests__/CarouselItem.test.d.ts +0 -1
- package/dist/components/carousel-component/__tests__/CarouselItem.test.js +0 -80
- package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.d.ts +0 -1
- package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +0 -62
- package/dist/components/carousel-component/__tests__/DefaultPageDot.test.d.ts +0 -1
- package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +0 -68
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +0 -1
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +0 -314
- package/dist/components/carousel-component/hooks/useCarousel.d.ts +0 -2
- package/dist/components/carousel-component/hooks/useCarousel.js +0 -140
- package/dist/components/carousel-component/index.d.ts +0 -4
- package/dist/components/carousel-component/index.js +0 -20
- package/dist/components/carousel-component/styles.d.ts +0 -30
- package/dist/components/carousel-component/styles.js +0 -120
- package/dist/components/carousel-component/types.d.ts +0 -46
- package/dist/components/carousel-component/types.js +0 -2
- package/dist/components/trip-cards/SkeletonCard.d.ts +0 -2
- package/dist/components/trip-cards/SkeletonCard.js +0 -21
- package/dist/components/trip-cards/TripCard.d.ts +0 -3
- package/dist/components/trip-cards/TripCard.js +0 -47
- package/dist/components/trip-cards/TripCards.stories.d.ts +0 -1
- package/dist/components/trip-cards/TripCards.stories.js +0 -40
- package/dist/components/trip-cards/TripCardsLayout.d.ts +0 -3
- package/dist/components/trip-cards/TripCardsLayout.js +0 -26
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +0 -139
- package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/TripCard.test.js +0 -95
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +0 -277
- package/dist/components/trip-cards/__tests__/assets.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/assets.test.js +0 -165
- package/dist/components/trip-cards/__tests__/helpers.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/helpers.test.js +0 -135
- package/dist/components/trip-cards/__tests__/index.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/index.test.js +0 -437
- package/dist/components/trip-cards/__tests__/mockData.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/mockData.test.js +0 -57
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +0 -194
- package/dist/components/trip-cards/assets/BoatIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/BoatIcon.js +0 -4
- package/dist/components/trip-cards/assets/CalendarIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/CalendarIcon.js +0 -4
- package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/ChevronRightIcon.js +0 -4
- package/dist/components/trip-cards/assets/LocationIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/LocationIcon.js +0 -4
- package/dist/components/trip-cards/assets/MoonIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/MoonIcon.js +0 -4
- package/dist/components/trip-cards/assets/index.d.ts +0 -6
- package/dist/components/trip-cards/assets/index.js +0 -7
- package/dist/components/trip-cards/helpers.d.ts +0 -4
- package/dist/components/trip-cards/helpers.js +0 -74
- package/dist/components/trip-cards/index.d.ts +0 -4
- package/dist/components/trip-cards/index.js +0 -70
- package/dist/components/trip-cards/mockData.d.ts +0 -3
- package/dist/components/trip-cards/mockData.js +0 -323
- package/dist/components/trip-cards/skeletonStyles.d.ts +0 -9
- package/dist/components/trip-cards/skeletonStyles.js +0 -37
- package/dist/components/trip-cards/styles.d.ts +0 -39
- package/dist/components/trip-cards/styles.js +0 -387
- package/dist/components/trip-cards/types.d.ts +0 -87
- package/src/components/carousel-component/CarouselComponent.stories.tsx +0 -220
- package/src/components/carousel-component/CarouselItem.tsx +0 -20
- package/src/components/carousel-component/DefaultNavigationArrow.tsx +0 -37
- package/src/components/carousel-component/DefaultPageDot.tsx +0 -20
- package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +0 -259
- package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +0 -140
- package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +0 -153
- package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +0 -105
- package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +0 -438
- package/src/components/carousel-component/hooks/useCarousel.ts +0 -187
- package/src/components/carousel-component/index.tsx +0 -88
- package/src/components/carousel-component/styles.ts +0 -140
- package/src/components/carousel-component/types.ts +0 -51
- package/src/components/trip-cards/SkeletonCard.tsx +0 -54
- package/src/components/trip-cards/TripCard.tsx +0 -135
- package/src/components/trip-cards/TripCards.stories.tsx +0 -67
- package/src/components/trip-cards/TripCardsLayout.tsx +0 -75
- package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +0 -169
- package/src/components/trip-cards/__tests__/TripCard.test.tsx +0 -120
- package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +0 -532
- package/src/components/trip-cards/__tests__/assets.test.tsx +0 -206
- package/src/components/trip-cards/__tests__/helpers.test.ts +0 -165
- package/src/components/trip-cards/__tests__/index.test.tsx +0 -499
- package/src/components/trip-cards/__tests__/mockData.test.ts +0 -67
- package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +0 -256
- package/src/components/trip-cards/assets/BoatIcon.tsx +0 -17
- package/src/components/trip-cards/assets/CalendarIcon.tsx +0 -17
- package/src/components/trip-cards/assets/ChevronRightIcon.tsx +0 -20
- package/src/components/trip-cards/assets/LocationIcon.tsx +0 -17
- package/src/components/trip-cards/assets/MoonIcon.tsx +0 -17
- package/src/components/trip-cards/assets/index.ts +0 -7
- package/src/components/trip-cards/helpers.ts +0 -99
- package/src/components/trip-cards/index.tsx +0 -104
- package/src/components/trip-cards/mockData.ts +0 -351
- package/src/components/trip-cards/skeletonStyles.ts +0 -46
- package/src/components/trip-cards/styles.ts +0 -426
- package/src/components/trip-cards/types.ts +0 -91
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { TripCards } from './index';
|
|
4
|
-
|
|
5
|
-
storiesOf('Typescript Component/TripCards', module)
|
|
6
|
-
.add('Default', () => (
|
|
7
|
-
<TripCards
|
|
8
|
-
element={{
|
|
9
|
-
class: 'trip-cards',
|
|
10
|
-
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
11
|
-
title: 'Similar cruises',
|
|
12
|
-
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
13
|
-
description: 'Brought to you by Times Holidays'
|
|
14
|
-
}}
|
|
15
|
-
useMockData={true}
|
|
16
|
-
/>
|
|
17
|
-
))
|
|
18
|
-
.add('Two Cards', () => (
|
|
19
|
-
<TripCards
|
|
20
|
-
element={{
|
|
21
|
-
class: 'trip-cards',
|
|
22
|
-
tripcards: btoa(JSON.stringify([2074350, 2140335])),
|
|
23
|
-
title: 'Similar cruises',
|
|
24
|
-
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
25
|
-
description: 'Brought to you by Times Holidays'
|
|
26
|
-
}}
|
|
27
|
-
useMockData={true}
|
|
28
|
-
/>
|
|
29
|
-
))
|
|
30
|
-
.add('Three Cards', () => (
|
|
31
|
-
<TripCards
|
|
32
|
-
element={{
|
|
33
|
-
class: 'trip-cards',
|
|
34
|
-
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
35
|
-
title: 'Similar cruises',
|
|
36
|
-
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
37
|
-
description: 'Brought to you by Times Holidays'
|
|
38
|
-
}}
|
|
39
|
-
useMockData={true}
|
|
40
|
-
/>
|
|
41
|
-
))
|
|
42
|
-
.add('Six Cards (Carousel)', () => (
|
|
43
|
-
<TripCards
|
|
44
|
-
element={{
|
|
45
|
-
class: 'trip-cards',
|
|
46
|
-
tripcards: btoa(
|
|
47
|
-
JSON.stringify([2074350, 2140335, 2177685, 2074351, 2140336, 2177686])
|
|
48
|
-
),
|
|
49
|
-
title: 'Featured Voyages',
|
|
50
|
-
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
51
|
-
description: 'Handpicked by our travel experts'
|
|
52
|
-
}}
|
|
53
|
-
useMockData={true}
|
|
54
|
-
/>
|
|
55
|
-
))
|
|
56
|
-
.add('With Title Link', () => (
|
|
57
|
-
<TripCards
|
|
58
|
-
element={{
|
|
59
|
-
class: 'trip-cards',
|
|
60
|
-
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
61
|
-
title: 'Explore Mediterranean',
|
|
62
|
-
titleUrl: 'https://www.thetimes.com/travel/holidays/cruises',
|
|
63
|
-
description: 'Discover amazing cruise deals'
|
|
64
|
-
}}
|
|
65
|
-
useMockData={true}
|
|
66
|
-
/>
|
|
67
|
-
));
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { CarouselComponent, CarouselItem } from '../carousel-component';
|
|
3
|
-
import { TripCardsLayoutProps } from './types';
|
|
4
|
-
import {
|
|
5
|
-
Container,
|
|
6
|
-
TitleSection,
|
|
7
|
-
TitleBar,
|
|
8
|
-
TitleContent,
|
|
9
|
-
Title,
|
|
10
|
-
Subtitle,
|
|
11
|
-
TitleLink,
|
|
12
|
-
StaticCardsGrid
|
|
13
|
-
} from './styles';
|
|
14
|
-
import { ChevronRightIcon } from './assets';
|
|
15
|
-
|
|
16
|
-
export const TripCardsLayout: FC<TripCardsLayoutProps> = ({
|
|
17
|
-
element,
|
|
18
|
-
items,
|
|
19
|
-
CardComponent,
|
|
20
|
-
itemsPerPage
|
|
21
|
-
}) => {
|
|
22
|
-
const { titleUrl, title, description } = element;
|
|
23
|
-
const isStaticGrid = items.length === 2;
|
|
24
|
-
return (
|
|
25
|
-
<Container data-testid="trip-cards-container">
|
|
26
|
-
<TitleSection data-testid="title-section">
|
|
27
|
-
<TitleBar data-testid="title-bar">
|
|
28
|
-
<TitleContent data-testid="title-content">
|
|
29
|
-
<Title data-testid="trip-cards-title">{title}</Title>
|
|
30
|
-
<Subtitle data-testid="trip-cards-subtitle">{description}</Subtitle>
|
|
31
|
-
</TitleContent>
|
|
32
|
-
{titleUrl && (
|
|
33
|
-
<TitleLink
|
|
34
|
-
href={titleUrl}
|
|
35
|
-
target="_blank"
|
|
36
|
-
rel="noopener noreferrer"
|
|
37
|
-
data-testid="title-link"
|
|
38
|
-
>
|
|
39
|
-
<ChevronRightIcon />
|
|
40
|
-
</TitleLink>
|
|
41
|
-
)}
|
|
42
|
-
</TitleBar>
|
|
43
|
-
</TitleSection>
|
|
44
|
-
|
|
45
|
-
{isStaticGrid ? (
|
|
46
|
-
<StaticCardsGrid data-testid="static-cards-grid">
|
|
47
|
-
{items.map(item => (
|
|
48
|
-
<CardComponent key={item.id} card={item.data} />
|
|
49
|
-
))}
|
|
50
|
-
</StaticCardsGrid>
|
|
51
|
-
) : (
|
|
52
|
-
<CarouselComponent
|
|
53
|
-
items={items.map(item => (
|
|
54
|
-
<CarouselItem
|
|
55
|
-
key={item.id}
|
|
56
|
-
widthConfig={{
|
|
57
|
-
mobile: '90%',
|
|
58
|
-
tablet: '43.5%',
|
|
59
|
-
desktop: '46.5%',
|
|
60
|
-
xl: '45.5%'
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<CardComponent card={item.data} />
|
|
64
|
-
</CarouselItem>
|
|
65
|
-
))}
|
|
66
|
-
options={{
|
|
67
|
-
itemsPerPage
|
|
68
|
-
}}
|
|
69
|
-
showArrows={true}
|
|
70
|
-
showDots={true}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
</Container>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { SkeletonCard } from '../SkeletonCard';
|
|
5
|
-
|
|
6
|
-
describe('SkeletonCard', () => {
|
|
7
|
-
it('renders without crashing', () => {
|
|
8
|
-
const { container } = render(<SkeletonCard />);
|
|
9
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('renders placeholder image', () => {
|
|
13
|
-
render(<SkeletonCard />);
|
|
14
|
-
const imageContainer = screen.getByTestId('skeleton-image-container');
|
|
15
|
-
expect(imageContainer).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders skeleton headline', () => {
|
|
19
|
-
render(<SkeletonCard />);
|
|
20
|
-
const skeletonHeadline = screen.getByTestId('skeleton-headline');
|
|
21
|
-
expect(skeletonHeadline).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('renders four skeleton data points in the list', () => {
|
|
25
|
-
render(<SkeletonCard />);
|
|
26
|
-
const dataPoints = [
|
|
27
|
-
screen.getByTestId('skeleton-data-point-1'),
|
|
28
|
-
screen.getByTestId('skeleton-data-point-2'),
|
|
29
|
-
screen.getByTestId('skeleton-data-point-3'),
|
|
30
|
-
screen.getByTestId('skeleton-data-point-4')
|
|
31
|
-
];
|
|
32
|
-
expect(dataPoints.length).toBe(4);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('renders skeleton lines for data points', () => {
|
|
36
|
-
render(<SkeletonCard />);
|
|
37
|
-
const skeletonLines = [
|
|
38
|
-
screen.getByTestId('skeleton-line-1'),
|
|
39
|
-
screen.getByTestId('skeleton-line-2'),
|
|
40
|
-
screen.getByTestId('skeleton-line-3'),
|
|
41
|
-
screen.getByTestId('skeleton-line-4'),
|
|
42
|
-
screen.getByTestId('skeleton-price-label')
|
|
43
|
-
];
|
|
44
|
-
expect(skeletonLines.length).toBe(5);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('renders skeleton price', () => {
|
|
48
|
-
render(<SkeletonCard />);
|
|
49
|
-
const skeletonPrice = screen.getByTestId('skeleton-price');
|
|
50
|
-
expect(skeletonPrice).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('renders skeleton button', () => {
|
|
54
|
-
render(<SkeletonCard />);
|
|
55
|
-
const skeletonButton = screen.getByTestId('skeleton-button');
|
|
56
|
-
expect(skeletonButton).toBeInTheDocument();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('has correct card structure', () => {
|
|
60
|
-
render(<SkeletonCard />);
|
|
61
|
-
const cardContainer = screen.getByTestId('skeleton-card-container');
|
|
62
|
-
const cardContent = screen.getByTestId('skeleton-card-content');
|
|
63
|
-
const topContainer = screen.getByTestId('skeleton-top-container');
|
|
64
|
-
const bottomContainer = screen.getByTestId('skeleton-bottom-container');
|
|
65
|
-
|
|
66
|
-
expect(cardContainer).toBeInTheDocument();
|
|
67
|
-
expect(cardContent).toBeInTheDocument();
|
|
68
|
-
expect(topContainer).toBeInTheDocument();
|
|
69
|
-
expect(bottomContainer).toBeInTheDocument();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('renders price section with container', () => {
|
|
73
|
-
render(<SkeletonCard />);
|
|
74
|
-
const priceSection = screen.getByTestId('skeleton-price-section');
|
|
75
|
-
const priceContainer = screen.getByTestId('skeleton-price-container');
|
|
76
|
-
|
|
77
|
-
expect(priceSection).toBeInTheDocument();
|
|
78
|
-
expect(priceContainer).toBeInTheDocument();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('renders data points list', () => {
|
|
82
|
-
render(<SkeletonCard />);
|
|
83
|
-
const dataPointsList = screen.getByTestId('skeleton-data-points-list');
|
|
84
|
-
expect(dataPointsList).toBeInTheDocument();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('skeleton lines are rendered for each data point', () => {
|
|
88
|
-
render(<SkeletonCard />);
|
|
89
|
-
const skeletonLines = [
|
|
90
|
-
screen.getByTestId('skeleton-line-1'),
|
|
91
|
-
screen.getByTestId('skeleton-line-2'),
|
|
92
|
-
screen.getByTestId('skeleton-line-3'),
|
|
93
|
-
screen.getByTestId('skeleton-line-4'),
|
|
94
|
-
screen.getByTestId('skeleton-price-label')
|
|
95
|
-
];
|
|
96
|
-
expect(skeletonLines.length).toBe(5);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('renders with correct skeleton styling', () => {
|
|
100
|
-
render(<SkeletonCard />);
|
|
101
|
-
|
|
102
|
-
expect(screen.getByTestId('skeleton-headline')).toBeInTheDocument();
|
|
103
|
-
expect(screen.getByTestId('skeleton-price')).toBeInTheDocument();
|
|
104
|
-
expect(screen.getByTestId('skeleton-button')).toBeInTheDocument();
|
|
105
|
-
// Check that skeleton lines are present
|
|
106
|
-
expect(screen.getByTestId('skeleton-line-1')).toBeInTheDocument();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('renders consistent structure', () => {
|
|
110
|
-
render(<SkeletonCard />);
|
|
111
|
-
|
|
112
|
-
expect(screen.getByTestId('skeleton-card-container')).toBeInTheDocument();
|
|
113
|
-
expect(screen.getByTestId('skeleton-image-container')).toBeInTheDocument();
|
|
114
|
-
expect(screen.getByTestId('skeleton-card-content')).toBeInTheDocument();
|
|
115
|
-
expect(screen.getByTestId('skeleton-top-container')).toBeInTheDocument();
|
|
116
|
-
expect(screen.getByTestId('skeleton-bottom-container')).toBeInTheDocument();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('can render multiple skeleton cards', () => {
|
|
120
|
-
render(
|
|
121
|
-
<>
|
|
122
|
-
<SkeletonCard />
|
|
123
|
-
<SkeletonCard />
|
|
124
|
-
<SkeletonCard />
|
|
125
|
-
</>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const cards = screen.getAllByTestId('skeleton-card-container');
|
|
129
|
-
expect(cards.length).toBe(3);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('renders skeleton elements in correct order', () => {
|
|
133
|
-
render(<SkeletonCard />);
|
|
134
|
-
|
|
135
|
-
const cardContent = screen.getByTestId('skeleton-card-content');
|
|
136
|
-
const topContainer = screen.getByTestId('skeleton-top-container');
|
|
137
|
-
const bottomContainer = screen.getByTestId('skeleton-bottom-container');
|
|
138
|
-
|
|
139
|
-
// Verify both containers exist as children of card content
|
|
140
|
-
expect(cardContent.contains(topContainer)).toBe(true);
|
|
141
|
-
expect(cardContent.contains(bottomContainer)).toBe(true);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('skeleton button has correct structure', () => {
|
|
145
|
-
render(<SkeletonCard />);
|
|
146
|
-
const skeletonButton = screen.getByTestId('skeleton-button');
|
|
147
|
-
|
|
148
|
-
expect(skeletonButton.tagName.toLowerCase()).toBe('div');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('skeleton lines have correct width props', () => {
|
|
152
|
-
render(<SkeletonCard />);
|
|
153
|
-
|
|
154
|
-
// Check that the skeleton lines are rendered
|
|
155
|
-
expect(screen.getByTestId('skeleton-line-1')).toBeInTheDocument();
|
|
156
|
-
expect(screen.getByTestId('skeleton-line-2')).toBeInTheDocument();
|
|
157
|
-
expect(screen.getByTestId('skeleton-line-3')).toBeInTheDocument();
|
|
158
|
-
expect(screen.getByTestId('skeleton-line-4')).toBeInTheDocument();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('renders without any interactive elements', () => {
|
|
162
|
-
const { container } = render(<SkeletonCard />);
|
|
163
|
-
const buttons = container.querySelectorAll('button');
|
|
164
|
-
const links = container.querySelectorAll('a');
|
|
165
|
-
|
|
166
|
-
expect(buttons.length).toBe(0);
|
|
167
|
-
expect(links.length).toBe(0);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { TripCard } from '../TripCard';
|
|
5
|
-
import { TripCardApiData } from '../types';
|
|
6
|
-
|
|
7
|
-
const mockCard: TripCardApiData = {
|
|
8
|
-
cruise_id: '2074350',
|
|
9
|
-
image: 'https://example.com/image.jpg',
|
|
10
|
-
headline: 'Mediterranean from Barcelona',
|
|
11
|
-
date: 'Oct 2025 - Oct 2025',
|
|
12
|
-
duration: 'Seven Days',
|
|
13
|
-
route: 'Barcelona → Marseille',
|
|
14
|
-
ship: 'MSC Seaside',
|
|
15
|
-
price: '£2000',
|
|
16
|
-
logo: 'https://example.com/logo.png',
|
|
17
|
-
logo_url: 'https://example.com',
|
|
18
|
-
cta_url: 'https://example.com/cruise',
|
|
19
|
-
cta_text: 'View Itinerary'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
describe('TripCard', () => {
|
|
23
|
-
it('renders card with all required data', () => {
|
|
24
|
-
render(<TripCard card={mockCard} />);
|
|
25
|
-
|
|
26
|
-
expect(
|
|
27
|
-
screen.getByText('Mediterranean from Barcelona')
|
|
28
|
-
).toBeInTheDocument();
|
|
29
|
-
expect(screen.getByText('Oct 2025 - Oct 2025')).toBeInTheDocument();
|
|
30
|
-
expect(screen.getByText('Seven Days')).toBeInTheDocument();
|
|
31
|
-
expect(screen.getByText('Barcelona → Marseille')).toBeInTheDocument();
|
|
32
|
-
expect(screen.getByText('MSC Seaside')).toBeInTheDocument();
|
|
33
|
-
expect(screen.getByText('£2000')).toBeInTheDocument();
|
|
34
|
-
expect(screen.getByText('From')).toBeInTheDocument();
|
|
35
|
-
expect(screen.getByText('View Itinerary')).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('renders image with correct src and alt', () => {
|
|
39
|
-
render(<TripCard card={mockCard} />);
|
|
40
|
-
|
|
41
|
-
const image = screen.getByAltText('Mediterranean from Barcelona');
|
|
42
|
-
expect(image).toHaveAttribute('src', 'https://example.com/image.jpg');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('renders offer label when provided', () => {
|
|
46
|
-
const cardWithOffer = {
|
|
47
|
-
...mockCard,
|
|
48
|
-
offer_label: 'Special Offer'
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
render(<TripCard card={cardWithOffer} />);
|
|
52
|
-
|
|
53
|
-
expect(screen.getByText('Special Offer')).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('renders gift banner when provided', () => {
|
|
57
|
-
const cardWithGift = {
|
|
58
|
-
...mockCard,
|
|
59
|
-
gift_banner: 'Free gift with purchase'
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
render(<TripCard card={cardWithGift} />);
|
|
63
|
-
|
|
64
|
-
expect(screen.getByText('Free gift with purchase')).toBeInTheDocument();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('renders original price when provided', () => {
|
|
68
|
-
const cardWithOriginalPrice = {
|
|
69
|
-
...mockCard,
|
|
70
|
-
original_price: '£2500'
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
render(<TripCard card={cardWithOriginalPrice} />);
|
|
74
|
-
|
|
75
|
-
expect(screen.getByText('£2500')).toBeInTheDocument();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('does not render "From" when price is "Enquire now"', () => {
|
|
79
|
-
const cardWithEnquire = {
|
|
80
|
-
...mockCard,
|
|
81
|
-
price: 'Enquire now'
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
render(<TripCard card={cardWithEnquire} />);
|
|
85
|
-
|
|
86
|
-
expect(screen.queryByText('From')).not.toBeInTheDocument();
|
|
87
|
-
expect(screen.getByText('Enquire now')).toBeInTheDocument();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('renders all CTA links with correct href and target', () => {
|
|
91
|
-
render(<TripCard card={mockCard} />);
|
|
92
|
-
|
|
93
|
-
const links = screen.getAllByRole('link');
|
|
94
|
-
const imageLink = links[0];
|
|
95
|
-
const headlineLink = links[1];
|
|
96
|
-
const ctaButton = screen.getByText('View Itinerary').closest('a');
|
|
97
|
-
|
|
98
|
-
expect(imageLink).toHaveAttribute('href', 'https://example.com/cruise');
|
|
99
|
-
expect(imageLink).toHaveAttribute('target', '_blank');
|
|
100
|
-
expect(headlineLink).toHaveAttribute('href', 'https://example.com/cruise');
|
|
101
|
-
expect(ctaButton).toHaveAttribute('href', 'https://example.com/cruise');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('renders logo with link when provided', () => {
|
|
105
|
-
render(<TripCard card={mockCard} />);
|
|
106
|
-
const logoLink = screen.getByRole('link', { name: /partner logo/i });
|
|
107
|
-
expect(logoLink).toHaveAttribute('href', 'https://example.com');
|
|
108
|
-
const logoImg = screen.getByAltText('Partner logo');
|
|
109
|
-
expect(logoImg).toHaveAttribute('src', 'https://example.com/logo.png');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('shows card image after it loads', () => {
|
|
113
|
-
render(<TripCard card={mockCard} />);
|
|
114
|
-
|
|
115
|
-
const cardImage = screen.getByAltText('Mediterranean from Barcelona');
|
|
116
|
-
expect(cardImage).toHaveStyle({ display: 'none' });
|
|
117
|
-
fireEvent.load(cardImage);
|
|
118
|
-
expect(cardImage).toHaveStyle({ display: 'block' });
|
|
119
|
-
});
|
|
120
|
-
});
|