@getmicdrop/svelte-components 2.0.4 → 2.0.6
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/Alert/Alert.spec.js +170 -170
- package/dist/components/Badges/Badge.spec.js +103 -103
- package/dist/components/BottomSheet/BottomSheet.spec.js +127 -127
- package/dist/components/Breadcrumb/Breadcrumb.spec.js +120 -120
- package/dist/components/Button/Button.spec.js +211 -211
- package/dist/components/Button/ButtonSaveDemo.spec.js +48 -48
- package/dist/components/Calendar/Calendar.spec.js +131 -131
- package/dist/components/Calendar/QuarterView.spec.js +394 -394
- package/dist/components/Card.spec.js +47 -47
- package/dist/components/CropImage/CropImage.spec.js +216 -216
- package/dist/components/DarkModeToggle.spec.js +357 -357
- package/dist/components/ErrorDisplay.spec.js +69 -69
- package/dist/components/FormActions.spec.js +88 -88
- package/dist/components/FormValidationSummary.spec.js +203 -203
- package/dist/components/Icons/Icon.spec.js +175 -175
- package/dist/components/Icons/MoreHori.spec.js +67 -67
- package/dist/components/Icons/WarningIcon.spec.js +30 -30
- package/dist/components/Input/Input.spec.js +573 -573
- package/dist/components/Input/MultiSelect.spec.js +257 -257
- package/dist/components/Input/OTPInput.spec.js +238 -238
- package/dist/components/Input/Select.spec.js +218 -218
- package/dist/components/Layout/BottomNav.spec.js +130 -130
- package/dist/components/Layout/Header.spec.js +203 -203
- package/dist/components/Modal/ConfirmationModal.spec.js +191 -191
- package/dist/components/Modal/Modal.spec.js +95 -95
- package/dist/components/Modal/ModalStateManager.spec.js +100 -100
- package/dist/components/PageLoader.spec.js +54 -54
- package/dist/components/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +173 -173
- package/dist/components/PlaceAutocomplete/PlaceAutocomplete.spec.js +300 -300
- package/dist/components/Spinner/Spinner.spec.js +75 -75
- package/dist/components/StatusIndicator/StatusIndicator.spec.js +129 -129
- package/dist/components/Toaster/Toaster.stories.svelte +1 -1
- package/dist/components/Toggle.spec.js +158 -158
- package/dist/components/ValidationError.spec.js +79 -79
- package/dist/components/pages/performers/AvailabilityCalendarModal.spec.js +606 -606
- package/dist/components/pages/performers/AvailabilityCalendarModal.svelte +4 -4
- package/dist/components/pages/performers/ModalShowInfo.spec.js +124 -124
- package/dist/components/pages/performers/ModalShowInfo.svelte +1 -1
- package/dist/components/pages/performers/PageBackButton.spec.js +89 -89
- package/dist/components/pages/performers/SectionHeader.spec.js +75 -75
- package/dist/components/pages/performers/ShowDetails.spec.js +166 -166
- package/dist/components/pages/performers/ShowItemCard.spec.js +793 -793
- package/dist/components/pages/performers/ShowItemCard.svelte +4 -4
- package/dist/components/pages/performers/SwitchOption.spec.js +127 -127
- package/dist/components/pages/performers/VenueInfo.spec.js +167 -167
- package/dist/components/pages/performers/VenueInfo.svelte +1 -1
- package/dist/components/pages/performers/VenueItemCard.spec.js +763 -763
- package/dist/components/pages/performers/VenueItemCard.svelte +4 -4
- package/dist/components/pages/profile/profile-form.spec.js +9 -9
- package/dist/components/pages/settings/tabs/CustomImageDropzone.svelte +3 -3
- package/dist/components/pages/shows/ShowList.spec.js +33 -33
- package/dist/components/pages/shows/TabContent.spec.js +90 -90
- package/dist/components/pages/shows/TabNavigation.spec.js +143 -143
- package/dist/config.js +5 -5
- package/dist/config.spec.js +29 -29
- package/dist/constants/formOptions.js +25 -25
- package/dist/constants/formOptions.spec.js +88 -88
- package/dist/index.js +111 -111
- package/dist/stores/auth.d.ts +9 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/auth.js +36 -0
- package/dist/stores/auth.spec.d.ts +2 -0
- package/dist/stores/auth.spec.d.ts.map +1 -0
- package/dist/stores/auth.spec.js +139 -0
- package/dist/stores/formDataStore.d.ts +17 -0
- package/dist/stores/formDataStore.d.ts.map +1 -0
- package/dist/stores/formDataStore.js +25 -0
- package/dist/stores/formDataStore.spec.d.ts +2 -0
- package/dist/stores/formDataStore.spec.d.ts.map +1 -0
- package/dist/stores/formDataStore.spec.js +257 -0
- package/dist/stores/formSave.d.ts +24 -0
- package/dist/stores/formSave.d.ts.map +1 -0
- package/dist/stores/formSave.js +132 -0
- package/dist/stores/formSave.spec.d.ts +2 -0
- package/dist/stores/formSave.spec.d.ts.map +1 -0
- package/dist/stores/formSave.spec.js +296 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +0 -0
- package/dist/stores/navigation.d.ts +5 -0
- package/dist/stores/navigation.d.ts.map +1 -0
- package/dist/stores/navigation.js +12 -0
- package/dist/stores/navigation.spec.d.ts +2 -0
- package/dist/stores/navigation.spec.d.ts.map +1 -0
- package/dist/stores/navigation.spec.js +136 -0
- package/dist/stores/toaster.d.ts +4 -0
- package/dist/stores/toaster.d.ts.map +1 -0
- package/dist/stores/toaster.js +13 -0
- package/dist/stores/toaster.spec.d.ts +2 -0
- package/dist/stores/toaster.spec.d.ts.map +1 -0
- package/dist/stores/toaster.spec.js +59 -0
- package/dist/telemetry.js +357 -357
- package/dist/telemetry.server.js +211 -211
- package/dist/telemetry.server.spec.js +434 -434
- package/dist/telemetry.spec.js +660 -660
- package/dist/utils/apiConfig.js +49 -49
- package/dist/utils/apiConfig.spec.js +118 -118
- package/dist/utils/greetings.js +187 -187
- package/dist/utils/greetings.spec.js +337 -337
- package/dist/utils/imageValidation.js +121 -121
- package/dist/utils/imageValidation.spec.js +220 -220
- package/dist/utils/portal.js +25 -25
- package/dist/utils/portal.spec.js +143 -143
- package/dist/utils/utils/utils.js +323 -323
- package/dist/utils/utils/utils.spec.js +698 -698
- package/dist/utils/utils.spec.js +643 -643
- package/package.json +1 -1
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { writable } from "svelte/store";
|
|
4
4
|
import { jwtDecode } from "jwt-decode";
|
|
5
5
|
import QuarterView from "../../Calendar/QuarterView.svelte";
|
|
6
|
-
import { timeAgo } from "
|
|
7
|
-
import { buildApiUrl, API_ENDPOINTS } from "
|
|
8
|
-
import { auth, initializeAuthState } from "
|
|
9
|
-
import microphonePlaceholder from "
|
|
6
|
+
import { timeAgo } from "../../utils/utils/utils";
|
|
7
|
+
import { buildApiUrl, API_ENDPOINTS } from "../../utils/apiConfig.js";
|
|
8
|
+
import { auth, initializeAuthState } from "../../stores/auth.js";
|
|
9
|
+
import microphonePlaceholder from "../../assets/images/microphone.png";
|
|
10
10
|
|
|
11
11
|
export let show = false;
|
|
12
12
|
export let venue = null;
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/svelte';
|
|
3
|
-
import ModalShowInfo from './ModalShowInfo.svelte';
|
|
4
|
-
|
|
5
|
-
// Mock the utils
|
|
6
|
-
vi.mock('@/utils/utils', () => ({
|
|
7
|
-
microphonePlaceholder: '/placeholder-mic.png',
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
describe('ModalShowInfo Component', () => {
|
|
11
|
-
const defaultProps = {
|
|
12
|
-
image: '/test-image.jpg',
|
|
13
|
-
title: 'Comedy Night',
|
|
14
|
-
showDate: 'Dec 25, 2025',
|
|
15
|
-
formattedStartTime: '8:00 PM',
|
|
16
|
-
venueName: 'The Laugh Factory',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
vi.clearAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('renders the component', () => {
|
|
24
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
25
|
-
expect(container.querySelector('.modal-show-info')).toBeDefined();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('renders the title', () => {
|
|
29
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
30
|
-
expect(container.querySelector('.modal-show-title').textContent).toBe('Comedy Night');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('renders the venue name', () => {
|
|
34
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
35
|
-
expect(container.querySelector('.modal-show-venue').textContent).toBe('The Laugh Factory');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('renders date and time when both provided', () => {
|
|
39
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
40
|
-
expect(container.querySelector('.modal-show-datetime').textContent).toContain('Dec 25, 2025');
|
|
41
|
-
expect(container.querySelector('.modal-show-datetime').textContent).toContain('8:00 PM');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders "No date yet" when showDate is missing', () => {
|
|
45
|
-
const props = { ...defaultProps, showDate: '', formattedStartTime: '8:00 PM' };
|
|
46
|
-
const { container } = render(ModalShowInfo, { props });
|
|
47
|
-
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('renders "No date yet" when formattedStartTime is missing', () => {
|
|
51
|
-
const props = { ...defaultProps, showDate: 'Dec 25, 2025', formattedStartTime: '' };
|
|
52
|
-
const { container } = render(ModalShowInfo, { props });
|
|
53
|
-
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('renders "No date yet" when both are missing', () => {
|
|
57
|
-
const props = { ...defaultProps, showDate: '', formattedStartTime: '' };
|
|
58
|
-
const { container } = render(ModalShowInfo, { props });
|
|
59
|
-
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('handles http image URLs directly', () => {
|
|
63
|
-
const props = { ...defaultProps, image: 'https://example.com/image.jpg' };
|
|
64
|
-
const { container } = render(ModalShowInfo, { props });
|
|
65
|
-
const img = container.querySelector('.modal-show-image img');
|
|
66
|
-
expect(img.src).toBe('https://example.com/image.jpg');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('prepends CDN URL for relative image paths', () => {
|
|
70
|
-
const props = { ...defaultProps, image: '/uploads/image.jpg' };
|
|
71
|
-
const { container } = render(ModalShowInfo, { props });
|
|
72
|
-
const img = container.querySelector('.modal-show-image img');
|
|
73
|
-
expect(img.src).toBe('https://moxy.sfo3.digitaloceanspaces.com/uploads/image.jpg');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('uses placeholder when image is empty', () => {
|
|
77
|
-
const props = { ...defaultProps, image: '' };
|
|
78
|
-
const { container } = render(ModalShowInfo, { props });
|
|
79
|
-
const img = container.querySelector('.modal-show-image img');
|
|
80
|
-
expect(img.src).toContain('placeholder-mic.png');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('uses placeholder when image is null', () => {
|
|
84
|
-
const props = { ...defaultProps, image: null };
|
|
85
|
-
const { container } = render(ModalShowInfo, { props });
|
|
86
|
-
const img = container.querySelector('.modal-show-image img');
|
|
87
|
-
expect(img.src).toContain('placeholder-mic.png');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('uses placeholder when image is undefined', () => {
|
|
91
|
-
const props = { ...defaultProps, image: undefined };
|
|
92
|
-
const { container } = render(ModalShowInfo, { props });
|
|
93
|
-
const img = container.querySelector('.modal-show-image img');
|
|
94
|
-
expect(img.src).toContain('placeholder-mic.png');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('sets alt text to title', () => {
|
|
98
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
99
|
-
const img = container.querySelector('.modal-show-image img');
|
|
100
|
-
expect(img.alt).toBe('Comedy Night');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('renders with empty venue name', () => {
|
|
104
|
-
const props = { ...defaultProps, venueName: '' };
|
|
105
|
-
const { container } = render(ModalShowInfo, { props });
|
|
106
|
-
expect(container.querySelector('.modal-show-venue').textContent).toBe('');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('renders with empty title', () => {
|
|
110
|
-
const props = { ...defaultProps, title: '' };
|
|
111
|
-
const { container } = render(ModalShowInfo, { props });
|
|
112
|
-
expect(container.querySelector('.modal-show-title').textContent).toBe('');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('renders show image container', () => {
|
|
116
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
117
|
-
expect(container.querySelector('.modal-show-image')).toBeDefined();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('renders show details container', () => {
|
|
121
|
-
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
122
|
-
expect(container.querySelector('.modal-show-details')).toBeDefined();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/svelte';
|
|
3
|
+
import ModalShowInfo from './ModalShowInfo.svelte';
|
|
4
|
+
|
|
5
|
+
// Mock the utils
|
|
6
|
+
vi.mock('@/utils/utils', () => ({
|
|
7
|
+
microphonePlaceholder: '/placeholder-mic.png',
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe('ModalShowInfo Component', () => {
|
|
11
|
+
const defaultProps = {
|
|
12
|
+
image: '/test-image.jpg',
|
|
13
|
+
title: 'Comedy Night',
|
|
14
|
+
showDate: 'Dec 25, 2025',
|
|
15
|
+
formattedStartTime: '8:00 PM',
|
|
16
|
+
venueName: 'The Laugh Factory',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders the component', () => {
|
|
24
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
25
|
+
expect(container.querySelector('.modal-show-info')).toBeDefined();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders the title', () => {
|
|
29
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
30
|
+
expect(container.querySelector('.modal-show-title').textContent).toBe('Comedy Night');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders the venue name', () => {
|
|
34
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
35
|
+
expect(container.querySelector('.modal-show-venue').textContent).toBe('The Laugh Factory');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders date and time when both provided', () => {
|
|
39
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
40
|
+
expect(container.querySelector('.modal-show-datetime').textContent).toContain('Dec 25, 2025');
|
|
41
|
+
expect(container.querySelector('.modal-show-datetime').textContent).toContain('8:00 PM');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders "No date yet" when showDate is missing', () => {
|
|
45
|
+
const props = { ...defaultProps, showDate: '', formattedStartTime: '8:00 PM' };
|
|
46
|
+
const { container } = render(ModalShowInfo, { props });
|
|
47
|
+
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('renders "No date yet" when formattedStartTime is missing', () => {
|
|
51
|
+
const props = { ...defaultProps, showDate: 'Dec 25, 2025', formattedStartTime: '' };
|
|
52
|
+
const { container } = render(ModalShowInfo, { props });
|
|
53
|
+
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders "No date yet" when both are missing', () => {
|
|
57
|
+
const props = { ...defaultProps, showDate: '', formattedStartTime: '' };
|
|
58
|
+
const { container } = render(ModalShowInfo, { props });
|
|
59
|
+
expect(container.querySelector('.modal-show-datetime').textContent.trim()).toBe('No date yet');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('handles http image URLs directly', () => {
|
|
63
|
+
const props = { ...defaultProps, image: 'https://example.com/image.jpg' };
|
|
64
|
+
const { container } = render(ModalShowInfo, { props });
|
|
65
|
+
const img = container.querySelector('.modal-show-image img');
|
|
66
|
+
expect(img.src).toBe('https://example.com/image.jpg');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('prepends CDN URL for relative image paths', () => {
|
|
70
|
+
const props = { ...defaultProps, image: '/uploads/image.jpg' };
|
|
71
|
+
const { container } = render(ModalShowInfo, { props });
|
|
72
|
+
const img = container.querySelector('.modal-show-image img');
|
|
73
|
+
expect(img.src).toBe('https://moxy.sfo3.digitaloceanspaces.com/uploads/image.jpg');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('uses placeholder when image is empty', () => {
|
|
77
|
+
const props = { ...defaultProps, image: '' };
|
|
78
|
+
const { container } = render(ModalShowInfo, { props });
|
|
79
|
+
const img = container.querySelector('.modal-show-image img');
|
|
80
|
+
expect(img.src).toContain('placeholder-mic.png');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('uses placeholder when image is null', () => {
|
|
84
|
+
const props = { ...defaultProps, image: null };
|
|
85
|
+
const { container } = render(ModalShowInfo, { props });
|
|
86
|
+
const img = container.querySelector('.modal-show-image img');
|
|
87
|
+
expect(img.src).toContain('placeholder-mic.png');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('uses placeholder when image is undefined', () => {
|
|
91
|
+
const props = { ...defaultProps, image: undefined };
|
|
92
|
+
const { container } = render(ModalShowInfo, { props });
|
|
93
|
+
const img = container.querySelector('.modal-show-image img');
|
|
94
|
+
expect(img.src).toContain('placeholder-mic.png');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('sets alt text to title', () => {
|
|
98
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
99
|
+
const img = container.querySelector('.modal-show-image img');
|
|
100
|
+
expect(img.alt).toBe('Comedy Night');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('renders with empty venue name', () => {
|
|
104
|
+
const props = { ...defaultProps, venueName: '' };
|
|
105
|
+
const { container } = render(ModalShowInfo, { props });
|
|
106
|
+
expect(container.querySelector('.modal-show-venue').textContent).toBe('');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renders with empty title', () => {
|
|
110
|
+
const props = { ...defaultProps, title: '' };
|
|
111
|
+
const { container } = render(ModalShowInfo, { props });
|
|
112
|
+
expect(container.querySelector('.modal-show-title').textContent).toBe('');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('renders show image container', () => {
|
|
116
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
117
|
+
expect(container.querySelector('.modal-show-image')).toBeDefined();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('renders show details container', () => {
|
|
121
|
+
const { container } = render(ModalShowInfo, { props: defaultProps });
|
|
122
|
+
expect(container.querySelector('.modal-show-details')).toBeDefined();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from "@testing-library/svelte";
|
|
2
|
-
import userEvent from "@testing-library/user-event";
|
|
3
|
-
import { expect, describe, test, vi, beforeEach } from "vitest";
|
|
4
|
-
import PageBackButton from "./PageBackButton.svelte";
|
|
5
|
-
|
|
6
|
-
// Mock history.back
|
|
7
|
-
const mockHistoryBack = vi.fn();
|
|
8
|
-
|
|
9
|
-
describe("PageBackButton Component Tests", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
vi.clearAllMocks();
|
|
12
|
-
// Mock history.back
|
|
13
|
-
Object.defineProperty(window, "history", {
|
|
14
|
-
value: {
|
|
15
|
-
back: mockHistoryBack,
|
|
16
|
-
},
|
|
17
|
-
writable: true,
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("Renders button element", () => {
|
|
22
|
-
render(PageBackButton, { props: { headerTitle: "Back" } });
|
|
23
|
-
const button = screen.getByRole("button");
|
|
24
|
-
expect(button).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("Renders header title", () => {
|
|
28
|
-
render(PageBackButton, { props: { headerTitle: "Profile Settings" } });
|
|
29
|
-
expect(screen.getByText("Profile Settings")).toBeInTheDocument();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("Has button type", () => {
|
|
33
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
34
|
-
const button = screen.getByRole("button");
|
|
35
|
-
expect(button).toHaveAttribute("type", "button");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("Calls history.back on click", async () => {
|
|
39
|
-
const user = userEvent.setup();
|
|
40
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
41
|
-
const button = screen.getByRole("button");
|
|
42
|
-
|
|
43
|
-
await user.click(button);
|
|
44
|
-
|
|
45
|
-
expect(mockHistoryBack).toHaveBeenCalledTimes(1);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("Has flexbox layout", () => {
|
|
49
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
50
|
-
const button = screen.getByRole("button");
|
|
51
|
-
expect(button).toHaveClass("flex");
|
|
52
|
-
expect(button).toHaveClass("items-center");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("Has correct typography classes", () => {
|
|
56
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
57
|
-
const button = screen.getByRole("button");
|
|
58
|
-
expect(button).toHaveClass("font-semibold");
|
|
59
|
-
expect(button).toHaveClass("text-xl");
|
|
60
|
-
expect(button).toHaveClass("text-Text-Primary");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("Contains Back icon", () => {
|
|
64
|
-
const { container } = render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
65
|
-
// Icon component should render an SVG
|
|
66
|
-
const svg = container.querySelector("svg");
|
|
67
|
-
expect(svg).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("Works with empty title", () => {
|
|
71
|
-
render(PageBackButton, { props: { headerTitle: "" } });
|
|
72
|
-
const button = screen.getByRole("button");
|
|
73
|
-
expect(button).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("Has responsive gap classes", () => {
|
|
77
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
78
|
-
const button = screen.getByRole("button");
|
|
79
|
-
expect(button.className).toMatch(/gap-1\.5/);
|
|
80
|
-
expect(button.className).toMatch(/sm:gap-2/);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("Has responsive margin classes", () => {
|
|
84
|
-
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
85
|
-
const button = screen.getByRole("button");
|
|
86
|
-
expect(button.className).toMatch(/my-0\.5/);
|
|
87
|
-
expect(button.className).toMatch(/sm:my-1/);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
1
|
+
import { render, screen, fireEvent } from "@testing-library/svelte";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { expect, describe, test, vi, beforeEach } from "vitest";
|
|
4
|
+
import PageBackButton from "./PageBackButton.svelte";
|
|
5
|
+
|
|
6
|
+
// Mock history.back
|
|
7
|
+
const mockHistoryBack = vi.fn();
|
|
8
|
+
|
|
9
|
+
describe("PageBackButton Component Tests", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vi.clearAllMocks();
|
|
12
|
+
// Mock history.back
|
|
13
|
+
Object.defineProperty(window, "history", {
|
|
14
|
+
value: {
|
|
15
|
+
back: mockHistoryBack,
|
|
16
|
+
},
|
|
17
|
+
writable: true,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("Renders button element", () => {
|
|
22
|
+
render(PageBackButton, { props: { headerTitle: "Back" } });
|
|
23
|
+
const button = screen.getByRole("button");
|
|
24
|
+
expect(button).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("Renders header title", () => {
|
|
28
|
+
render(PageBackButton, { props: { headerTitle: "Profile Settings" } });
|
|
29
|
+
expect(screen.getByText("Profile Settings")).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Has button type", () => {
|
|
33
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
34
|
+
const button = screen.getByRole("button");
|
|
35
|
+
expect(button).toHaveAttribute("type", "button");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("Calls history.back on click", async () => {
|
|
39
|
+
const user = userEvent.setup();
|
|
40
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
41
|
+
const button = screen.getByRole("button");
|
|
42
|
+
|
|
43
|
+
await user.click(button);
|
|
44
|
+
|
|
45
|
+
expect(mockHistoryBack).toHaveBeenCalledTimes(1);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Has flexbox layout", () => {
|
|
49
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
50
|
+
const button = screen.getByRole("button");
|
|
51
|
+
expect(button).toHaveClass("flex");
|
|
52
|
+
expect(button).toHaveClass("items-center");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("Has correct typography classes", () => {
|
|
56
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
57
|
+
const button = screen.getByRole("button");
|
|
58
|
+
expect(button).toHaveClass("font-semibold");
|
|
59
|
+
expect(button).toHaveClass("text-xl");
|
|
60
|
+
expect(button).toHaveClass("text-Text-Primary");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("Contains Back icon", () => {
|
|
64
|
+
const { container } = render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
65
|
+
// Icon component should render an SVG
|
|
66
|
+
const svg = container.querySelector("svg");
|
|
67
|
+
expect(svg).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("Works with empty title", () => {
|
|
71
|
+
render(PageBackButton, { props: { headerTitle: "" } });
|
|
72
|
+
const button = screen.getByRole("button");
|
|
73
|
+
expect(button).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("Has responsive gap classes", () => {
|
|
77
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
78
|
+
const button = screen.getByRole("button");
|
|
79
|
+
expect(button.className).toMatch(/gap-1\.5/);
|
|
80
|
+
expect(button.className).toMatch(/sm:gap-2/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("Has responsive margin classes", () => {
|
|
84
|
+
render(PageBackButton, { props: { headerTitle: "Title" } });
|
|
85
|
+
const button = screen.getByRole("button");
|
|
86
|
+
expect(button.className).toMatch(/my-0\.5/);
|
|
87
|
+
expect(button.className).toMatch(/sm:my-1/);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/svelte";
|
|
2
|
-
import { expect, describe, test } from "vitest";
|
|
3
|
-
import SectionHeader from "./SectionHeader.svelte";
|
|
4
|
-
|
|
5
|
-
describe("SectionHeader Component Tests", () => {
|
|
6
|
-
test("Renders title", () => {
|
|
7
|
-
render(SectionHeader, { props: { title: "Header Title" } });
|
|
8
|
-
expect(screen.getByText("Header Title")).toBeInTheDocument();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test("Renders description", () => {
|
|
12
|
-
render(SectionHeader, {
|
|
13
|
-
props: { title: "Title", description: "This is a description" },
|
|
14
|
-
});
|
|
15
|
-
expect(screen.getByText("This is a description")).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("Renders both title and description", () => {
|
|
19
|
-
render(SectionHeader, {
|
|
20
|
-
props: { title: "My Title", description: "My Description" },
|
|
21
|
-
});
|
|
22
|
-
expect(screen.getByText("My Title")).toBeInTheDocument();
|
|
23
|
-
expect(screen.getByText("My Description")).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("Title is h3 element", () => {
|
|
27
|
-
render(SectionHeader, { props: { title: "Title", description: "" } });
|
|
28
|
-
const title = screen.getByText("Title");
|
|
29
|
-
expect(title.tagName).toBe("H3");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("Description is p element", () => {
|
|
33
|
-
render(SectionHeader, {
|
|
34
|
-
props: { title: "Title", description: "Description" },
|
|
35
|
-
});
|
|
36
|
-
const description = screen.getByText("Description");
|
|
37
|
-
expect(description.tagName).toBe("P");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("Title has correct styling", () => {
|
|
41
|
-
render(SectionHeader, { props: { title: "Title", description: "" } });
|
|
42
|
-
const title = screen.getByText("Title");
|
|
43
|
-
expect(title).toHaveClass("font-semibold");
|
|
44
|
-
expect(title).toHaveClass("text-Text-Primary");
|
|
45
|
-
expect(title).toHaveClass("text-xl");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("Description has correct styling", () => {
|
|
49
|
-
render(SectionHeader, {
|
|
50
|
-
props: { title: "Title", description: "Description" },
|
|
51
|
-
});
|
|
52
|
-
const description = screen.getByText("Description");
|
|
53
|
-
expect(description).toHaveClass("text-sm");
|
|
54
|
-
expect(description).toHaveClass("text-Text-Tartiary");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("Works with empty title", () => {
|
|
58
|
-
render(SectionHeader, { props: { title: "", description: "Only description" } });
|
|
59
|
-
expect(screen.getByText("Only description")).toBeInTheDocument();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("Works with empty description", () => {
|
|
63
|
-
render(SectionHeader, { props: { title: "Only title", description: "" } });
|
|
64
|
-
expect(screen.getByText("Only title")).toBeInTheDocument();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test("Works with default empty props", () => {
|
|
68
|
-
const { container } = render(SectionHeader, { props: {} });
|
|
69
|
-
const h3 = container.querySelector("h3");
|
|
70
|
-
const p = container.querySelector("p");
|
|
71
|
-
expect(h3).toBeInTheDocument();
|
|
72
|
-
// Description is conditionally rendered - only appears when provided
|
|
73
|
-
expect(p).not.toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
1
|
+
import { render, screen } from "@testing-library/svelte";
|
|
2
|
+
import { expect, describe, test } from "vitest";
|
|
3
|
+
import SectionHeader from "./SectionHeader.svelte";
|
|
4
|
+
|
|
5
|
+
describe("SectionHeader Component Tests", () => {
|
|
6
|
+
test("Renders title", () => {
|
|
7
|
+
render(SectionHeader, { props: { title: "Header Title" } });
|
|
8
|
+
expect(screen.getByText("Header Title")).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("Renders description", () => {
|
|
12
|
+
render(SectionHeader, {
|
|
13
|
+
props: { title: "Title", description: "This is a description" },
|
|
14
|
+
});
|
|
15
|
+
expect(screen.getByText("This is a description")).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("Renders both title and description", () => {
|
|
19
|
+
render(SectionHeader, {
|
|
20
|
+
props: { title: "My Title", description: "My Description" },
|
|
21
|
+
});
|
|
22
|
+
expect(screen.getByText("My Title")).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText("My Description")).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("Title is h3 element", () => {
|
|
27
|
+
render(SectionHeader, { props: { title: "Title", description: "" } });
|
|
28
|
+
const title = screen.getByText("Title");
|
|
29
|
+
expect(title.tagName).toBe("H3");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Description is p element", () => {
|
|
33
|
+
render(SectionHeader, {
|
|
34
|
+
props: { title: "Title", description: "Description" },
|
|
35
|
+
});
|
|
36
|
+
const description = screen.getByText("Description");
|
|
37
|
+
expect(description.tagName).toBe("P");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("Title has correct styling", () => {
|
|
41
|
+
render(SectionHeader, { props: { title: "Title", description: "" } });
|
|
42
|
+
const title = screen.getByText("Title");
|
|
43
|
+
expect(title).toHaveClass("font-semibold");
|
|
44
|
+
expect(title).toHaveClass("text-Text-Primary");
|
|
45
|
+
expect(title).toHaveClass("text-xl");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Description has correct styling", () => {
|
|
49
|
+
render(SectionHeader, {
|
|
50
|
+
props: { title: "Title", description: "Description" },
|
|
51
|
+
});
|
|
52
|
+
const description = screen.getByText("Description");
|
|
53
|
+
expect(description).toHaveClass("text-sm");
|
|
54
|
+
expect(description).toHaveClass("text-Text-Tartiary");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("Works with empty title", () => {
|
|
58
|
+
render(SectionHeader, { props: { title: "", description: "Only description" } });
|
|
59
|
+
expect(screen.getByText("Only description")).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("Works with empty description", () => {
|
|
63
|
+
render(SectionHeader, { props: { title: "Only title", description: "" } });
|
|
64
|
+
expect(screen.getByText("Only title")).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("Works with default empty props", () => {
|
|
68
|
+
const { container } = render(SectionHeader, { props: {} });
|
|
69
|
+
const h3 = container.querySelector("h3");
|
|
70
|
+
const p = container.querySelector("p");
|
|
71
|
+
expect(h3).toBeInTheDocument();
|
|
72
|
+
// Description is conditionally rendered - only appears when provided
|
|
73
|
+
expect(p).not.toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
});
|