@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,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationArrowButton } from './styles';
|
|
3
|
-
|
|
4
|
-
interface NavigationArrowProps {
|
|
5
|
-
direction: 'left' | 'right';
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
disabled: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DefaultNavigationArrow: React.FC<NavigationArrowProps> = ({
|
|
11
|
-
direction,
|
|
12
|
-
onClick,
|
|
13
|
-
disabled
|
|
14
|
-
}) => (
|
|
15
|
-
<NavigationArrowButton
|
|
16
|
-
direction={direction}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
disabled={disabled}
|
|
19
|
-
aria-label={`${direction === 'left' ? 'Previous' : 'Next'} items`}
|
|
20
|
-
>
|
|
21
|
-
<svg
|
|
22
|
-
width="24"
|
|
23
|
-
height="24"
|
|
24
|
-
viewBox="0 0 16 16"
|
|
25
|
-
fill="none"
|
|
26
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
-
>
|
|
28
|
-
<path
|
|
29
|
-
d={direction === 'left' ? 'M10 12L6 8L10 4' : 'M6 12L10 8L6 4'}
|
|
30
|
-
stroke="currentColor"
|
|
31
|
-
strokeWidth="1.5"
|
|
32
|
-
strokeLinecap="round"
|
|
33
|
-
strokeLinejoin="round"
|
|
34
|
-
/>
|
|
35
|
-
</svg>
|
|
36
|
-
</NavigationArrowButton>
|
|
37
|
-
);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PageDotButton } from './styles';
|
|
3
|
-
|
|
4
|
-
interface PageDotProps {
|
|
5
|
-
active: boolean;
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
index: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DefaultPageDot: React.FC<PageDotProps> = ({
|
|
11
|
-
active,
|
|
12
|
-
onClick,
|
|
13
|
-
index
|
|
14
|
-
}) => (
|
|
15
|
-
<PageDotButton
|
|
16
|
-
active={active}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
aria-label={`Go to page ${index + 1}`}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { CarouselComponent } from '../index';
|
|
5
|
-
|
|
6
|
-
describe('CarouselComponent', () => {
|
|
7
|
-
const mockItems = [
|
|
8
|
-
<div key="1">Item 1</div>,
|
|
9
|
-
<div key="2">Item 2</div>,
|
|
10
|
-
<div key="3">Item 3</div>,
|
|
11
|
-
<div key="4">Item 4</div>
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
Element.prototype.scrollTo = jest.fn();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders all items', () => {
|
|
19
|
-
render(<CarouselComponent items={mockItems} />);
|
|
20
|
-
|
|
21
|
-
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
22
|
-
expect(screen.getByText('Item 2')).toBeInTheDocument();
|
|
23
|
-
expect(screen.getByText('Item 3')).toBeInTheDocument();
|
|
24
|
-
expect(screen.getByText('Item 4')).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('renders navigation arrows by default', () => {
|
|
28
|
-
render(<CarouselComponent items={mockItems} />);
|
|
29
|
-
|
|
30
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
31
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
32
|
-
|
|
33
|
-
expect(prevButton).toBeInTheDocument();
|
|
34
|
-
expect(nextButton).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('hides navigation arrows when showArrows is false', () => {
|
|
38
|
-
render(<CarouselComponent items={mockItems} showArrows={false} />);
|
|
39
|
-
|
|
40
|
-
const buttons = screen.getAllByRole('button');
|
|
41
|
-
expect(buttons.length).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders pagination dots by default', () => {
|
|
45
|
-
render(<CarouselComponent items={mockItems} />);
|
|
46
|
-
|
|
47
|
-
const dots = screen
|
|
48
|
-
.getAllByRole('button')
|
|
49
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
50
|
-
|
|
51
|
-
expect(dots.length).toBeGreaterThan(0);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('hides pagination dots when showDots is false', () => {
|
|
55
|
-
render(
|
|
56
|
-
<CarouselComponent
|
|
57
|
-
items={mockItems}
|
|
58
|
-
showDots={false}
|
|
59
|
-
showArrows={false}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const buttons = screen.queryAllByRole('button');
|
|
64
|
-
|
|
65
|
-
expect(buttons.length).toBe(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('applies custom className', () => {
|
|
69
|
-
const { container } = render(
|
|
70
|
-
<CarouselComponent items={mockItems} className="custom-carousel" />
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
expect(container.querySelector('.custom-carousel')).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('handles itemsPerPage option', () => {
|
|
77
|
-
render(
|
|
78
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 1 }} />
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const dots = screen
|
|
82
|
-
.getAllByRole('button')
|
|
83
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
84
|
-
|
|
85
|
-
expect(dots.length).toBe(4);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('handles empty items array', () => {
|
|
89
|
-
const { container } = render(<CarouselComponent items={[]} />);
|
|
90
|
-
|
|
91
|
-
expect(container.querySelector('[role="button"]')).not.toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('handles single item', () => {
|
|
95
|
-
render(<CarouselComponent items={[<div key="1">Single Item</div>]} />);
|
|
96
|
-
|
|
97
|
-
expect(screen.getByText('Single Item')).toBeInTheDocument();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('calls onPageChange callback when provided', () => {
|
|
101
|
-
const onPageChange = jest.fn();
|
|
102
|
-
|
|
103
|
-
render(<CarouselComponent items={mockItems} options={{ onPageChange }} />);
|
|
104
|
-
|
|
105
|
-
const nextButton = screen
|
|
106
|
-
.getAllByRole('button')
|
|
107
|
-
.find(btn => btn.querySelector('svg'));
|
|
108
|
-
|
|
109
|
-
if (nextButton) {
|
|
110
|
-
fireEvent.click(nextButton);
|
|
111
|
-
expect(onPageChange).toHaveBeenCalled();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('renders with custom arrow component', () => {
|
|
116
|
-
const CustomArrow = ({ direction }: { direction: string }) => (
|
|
117
|
-
<button>Custom {direction}</button>
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
render(
|
|
121
|
-
<CarouselComponent
|
|
122
|
-
items={mockItems}
|
|
123
|
-
arrowComponent={CustomArrow as any}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const customArrows = screen.getAllByText(/Custom/);
|
|
128
|
-
expect(customArrows.length).toBe(2);
|
|
129
|
-
expect(customArrows[0]).toBeInTheDocument();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('renders with custom dot component', () => {
|
|
133
|
-
const CustomDot = ({ index }: { index: number }) => (
|
|
134
|
-
<button>Dot {index}</button>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
render(
|
|
138
|
-
<CarouselComponent items={mockItems} dotComponent={CustomDot as any} />
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const customDots = screen.getAllByText(/Dot/);
|
|
142
|
-
expect(customDots.length).toBe(2);
|
|
143
|
-
expect(customDots[0]).toBeInTheDocument();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('navigates to next page when next arrow is clicked', () => {
|
|
147
|
-
render(
|
|
148
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
152
|
-
fireEvent.click(nextButton);
|
|
153
|
-
|
|
154
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('navigates to previous page when previous arrow is clicked', () => {
|
|
158
|
-
render(
|
|
159
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
163
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
164
|
-
|
|
165
|
-
fireEvent.click(nextButton);
|
|
166
|
-
fireEvent.click(prevButton);
|
|
167
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('handles mouse drag events', () => {
|
|
171
|
-
const { container } = render(
|
|
172
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
const carouselRow = container.querySelector('div > div > div');
|
|
176
|
-
|
|
177
|
-
if (carouselRow) {
|
|
178
|
-
fireEvent.mouseDown(carouselRow, { pageX: 100 });
|
|
179
|
-
fireEvent.mouseMove(carouselRow, { pageX: 50 });
|
|
180
|
-
fireEvent.mouseUp(carouselRow);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
expect(carouselRow).toBeInTheDocument();
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('disables previous arrow on first page', () => {
|
|
187
|
-
render(
|
|
188
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
192
|
-
expect(prevButton).toBeDisabled();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('renders correct number of page dots', () => {
|
|
196
|
-
render(
|
|
197
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const dots = screen
|
|
201
|
-
.getAllByRole('button')
|
|
202
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
203
|
-
|
|
204
|
-
expect(dots.length).toBe(2);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('handles page dot click', () => {
|
|
208
|
-
render(
|
|
209
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const dots = screen
|
|
213
|
-
.getAllByRole('button')
|
|
214
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
215
|
-
|
|
216
|
-
if (dots[1]) {
|
|
217
|
-
fireEvent.click(dots[1]);
|
|
218
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('hides dots when there is only one page', () => {
|
|
223
|
-
render(
|
|
224
|
-
<CarouselComponent
|
|
225
|
-
items={[<div key="1">Item 1</div>]}
|
|
226
|
-
options={{ itemsPerPage: 2 }}
|
|
227
|
-
/>
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
const dots = screen
|
|
231
|
-
.queryAllByRole('button')
|
|
232
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
233
|
-
|
|
234
|
-
expect(dots.length).toBe(0);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('handles mouse leave event during drag', () => {
|
|
238
|
-
const { container } = render(
|
|
239
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
const carouselRow = container.querySelector('div > div > div');
|
|
243
|
-
|
|
244
|
-
if (carouselRow) {
|
|
245
|
-
fireEvent.mouseDown(carouselRow, { pageX: 100 });
|
|
246
|
-
fireEvent.mouseMove(carouselRow, { pageX: 50 });
|
|
247
|
-
fireEvent.mouseLeave(carouselRow);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
expect(carouselRow).toBeInTheDocument();
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('applies correct styles to carousel container', () => {
|
|
254
|
-
const { container } = render(<CarouselComponent items={mockItems} />);
|
|
255
|
-
|
|
256
|
-
const carouselContainer = container.firstChild;
|
|
257
|
-
expect(carouselContainer).toBeInTheDocument();
|
|
258
|
-
});
|
|
259
|
-
});
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { CarouselItem } from '../CarouselItem';
|
|
5
|
-
|
|
6
|
-
describe('CarouselItem', () => {
|
|
7
|
-
it('renders children correctly', () => {
|
|
8
|
-
render(
|
|
9
|
-
<CarouselItem>
|
|
10
|
-
<div>Test Content</div>
|
|
11
|
-
</CarouselItem>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('applies custom className', () => {
|
|
18
|
-
const { container } = render(
|
|
19
|
-
<CarouselItem className="custom-class">
|
|
20
|
-
<div>Test Content</div>
|
|
21
|
-
</CarouselItem>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
expect(container.firstChild).toHaveClass('custom-class');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('uses default widthConfig when not provided', () => {
|
|
28
|
-
const { container } = render(
|
|
29
|
-
<CarouselItem>
|
|
30
|
-
<div>Test Content</div>
|
|
31
|
-
</CarouselItem>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('accepts custom widthConfig', () => {
|
|
38
|
-
render(
|
|
39
|
-
<CarouselItem
|
|
40
|
-
widthConfig={{
|
|
41
|
-
xs: '70%',
|
|
42
|
-
mobile: '90%',
|
|
43
|
-
tablet: '45%',
|
|
44
|
-
desktop: '30%',
|
|
45
|
-
xl: '25%'
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<div>Test Content</div>
|
|
49
|
-
</CarouselItem>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('accepts partial widthConfig', () => {
|
|
56
|
-
render(
|
|
57
|
-
<CarouselItem
|
|
58
|
-
widthConfig={{
|
|
59
|
-
mobile: '80%',
|
|
60
|
-
desktop: '40%'
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<div>Test Content</div>
|
|
64
|
-
</CarouselItem>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('renders multiple children correctly', () => {
|
|
71
|
-
render(
|
|
72
|
-
<CarouselItem>
|
|
73
|
-
<div>Child 1</div>
|
|
74
|
-
<div>Child 2</div>
|
|
75
|
-
<div>Child 3</div>
|
|
76
|
-
</CarouselItem>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
expect(screen.getByText('Child 1')).toBeInTheDocument();
|
|
80
|
-
expect(screen.getByText('Child 2')).toBeInTheDocument();
|
|
81
|
-
expect(screen.getByText('Child 3')).toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('handles complex child components', () => {
|
|
85
|
-
const ComplexChild = () => (
|
|
86
|
-
<div>
|
|
87
|
-
<h1>Title</h1>
|
|
88
|
-
<p>Description</p>
|
|
89
|
-
<button>Action</button>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
render(
|
|
94
|
-
<CarouselItem>
|
|
95
|
-
<ComplexChild />
|
|
96
|
-
</CarouselItem>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
expect(screen.getByText('Title')).toBeInTheDocument();
|
|
100
|
-
expect(screen.getByText('Description')).toBeInTheDocument();
|
|
101
|
-
expect(screen.getByText('Action')).toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('applies className along with widthConfig', () => {
|
|
105
|
-
const { container } = render(
|
|
106
|
-
<CarouselItem
|
|
107
|
-
className="custom-item"
|
|
108
|
-
widthConfig={{
|
|
109
|
-
mobile: '90%',
|
|
110
|
-
desktop: '45%'
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
<div>Test Content</div>
|
|
114
|
-
</CarouselItem>
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
expect(container.firstChild).toHaveClass('custom-item');
|
|
118
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('renders with no props except children', () => {
|
|
122
|
-
render(
|
|
123
|
-
<CarouselItem>
|
|
124
|
-
<div>Minimal Content</div>
|
|
125
|
-
</CarouselItem>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
expect(screen.getByText('Minimal Content')).toBeInTheDocument();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('handles empty widthConfig object', () => {
|
|
132
|
-
render(
|
|
133
|
-
<CarouselItem widthConfig={{}}>
|
|
134
|
-
<div>Test Content</div>
|
|
135
|
-
</CarouselItem>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { DefaultNavigationArrow } from '../DefaultNavigationArrow';
|
|
5
|
-
|
|
6
|
-
describe('DefaultNavigationArrow', () => {
|
|
7
|
-
const mockOnClick = jest.fn();
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
mockOnClick.mockClear();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('renders left arrow', () => {
|
|
14
|
-
render(
|
|
15
|
-
<DefaultNavigationArrow
|
|
16
|
-
direction="left"
|
|
17
|
-
onClick={mockOnClick}
|
|
18
|
-
disabled={false}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const button = screen.getByLabelText('Previous items');
|
|
23
|
-
expect(button).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('renders right arrow', () => {
|
|
27
|
-
render(
|
|
28
|
-
<DefaultNavigationArrow
|
|
29
|
-
direction="right"
|
|
30
|
-
onClick={mockOnClick}
|
|
31
|
-
disabled={false}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const button = screen.getByLabelText('Next items');
|
|
36
|
-
expect(button).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('calls onClick when clicked', () => {
|
|
40
|
-
render(
|
|
41
|
-
<DefaultNavigationArrow
|
|
42
|
-
direction="left"
|
|
43
|
-
onClick={mockOnClick}
|
|
44
|
-
disabled={false}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const button = screen.getByLabelText('Previous items');
|
|
49
|
-
fireEvent.click(button);
|
|
50
|
-
|
|
51
|
-
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('does not call onClick when disabled', () => {
|
|
55
|
-
render(
|
|
56
|
-
<DefaultNavigationArrow
|
|
57
|
-
direction="left"
|
|
58
|
-
onClick={mockOnClick}
|
|
59
|
-
disabled={true}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const button = screen.getByLabelText('Previous items');
|
|
64
|
-
fireEvent.click(button);
|
|
65
|
-
|
|
66
|
-
expect(mockOnClick).not.toHaveBeenCalled();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('applies disabled styling when disabled', () => {
|
|
70
|
-
render(
|
|
71
|
-
<DefaultNavigationArrow
|
|
72
|
-
direction="left"
|
|
73
|
-
onClick={mockOnClick}
|
|
74
|
-
disabled={true}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const button = screen.getByLabelText('Previous items');
|
|
79
|
-
expect(button).toHaveAttribute('disabled');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('renders SVG icon', () => {
|
|
83
|
-
const { container } = render(
|
|
84
|
-
<DefaultNavigationArrow
|
|
85
|
-
direction="left"
|
|
86
|
-
onClick={mockOnClick}
|
|
87
|
-
disabled={false}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const svg = container.querySelector('svg');
|
|
92
|
-
expect(svg).toBeInTheDocument();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('has correct aria-label for accessibility', () => {
|
|
96
|
-
const { rerender } = render(
|
|
97
|
-
<DefaultNavigationArrow
|
|
98
|
-
direction="left"
|
|
99
|
-
onClick={mockOnClick}
|
|
100
|
-
disabled={false}
|
|
101
|
-
/>
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(screen.getByLabelText('Previous items')).toBeInTheDocument();
|
|
105
|
-
|
|
106
|
-
rerender(
|
|
107
|
-
<DefaultNavigationArrow
|
|
108
|
-
direction="right"
|
|
109
|
-
onClick={mockOnClick}
|
|
110
|
-
disabled={false}
|
|
111
|
-
/>
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
expect(screen.getByLabelText('Next items')).toBeInTheDocument();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('renders as a button element', () => {
|
|
118
|
-
render(
|
|
119
|
-
<DefaultNavigationArrow
|
|
120
|
-
direction="left"
|
|
121
|
-
onClick={mockOnClick}
|
|
122
|
-
disabled={false}
|
|
123
|
-
/>
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
const button = screen.getByLabelText('Previous items');
|
|
127
|
-
expect(button.tagName).toBe('BUTTON');
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('applies correct styles based on direction', () => {
|
|
131
|
-
const { container, rerender } = render(
|
|
132
|
-
<DefaultNavigationArrow
|
|
133
|
-
direction="left"
|
|
134
|
-
onClick={mockOnClick}
|
|
135
|
-
disabled={false}
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
let button = container.querySelector('button');
|
|
140
|
-
expect(button).toBeInTheDocument();
|
|
141
|
-
|
|
142
|
-
rerender(
|
|
143
|
-
<DefaultNavigationArrow
|
|
144
|
-
direction="right"
|
|
145
|
-
onClick={mockOnClick}
|
|
146
|
-
disabled={false}
|
|
147
|
-
/>
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
button = container.querySelector('button');
|
|
151
|
-
expect(button).toBeInTheDocument();
|
|
152
|
-
});
|
|
153
|
-
});
|