@astryxdesign/core 0.1.2-canary.cac8ed5 → 0.1.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/Calendar/Calendar.d.ts +4 -5
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +1 -6
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Calendar/index.d.ts.map +1 -1
- package/dist/astryx.umd.js +28 -28
- package/dist/astryx.umd.js.map +4 -4
- package/dist/utils/dateTypes.d.ts +0 -12
- package/dist/utils/dateTypes.d.ts.map +1 -1
- package/dist/utils/dateTypes.js +1 -41
- package/package.json +1 -1
- package/src/Calendar/Calendar.doc.mjs +4 -4
- package/src/Calendar/Calendar.test.tsx +26 -21
- package/src/Calendar/Calendar.tsx +5 -21
- package/src/Calendar/index.ts +0 -1
- package/src/Dialog/Dialog.doc.mjs +2 -2
- package/src/Table/useTableColumnResize.doc.mjs +3 -3
- package/src/Table/useTableStickyColumns.doc.mjs +2 -2
- package/src/utils/dateTypes.ts +0 -40
- package/src/utils/dateTypes.test.ts +0 -40
|
@@ -11,18 +11,6 @@
|
|
|
11
11
|
export type ISODateString = `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
|
|
12
12
|
/** Day of week: 0 = Sunday through 6 = Saturday */
|
|
13
13
|
export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
|
-
/**
|
|
15
|
-
* Three-letter lowercase weekday name, 'sun' through 'sat'.
|
|
16
|
-
* A more self-documenting alternative to the numeric {@link DayOfWeek}.
|
|
17
|
-
*/
|
|
18
|
-
export type DayOfWeekName = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
|
|
19
|
-
/**
|
|
20
|
-
* Normalize a weekday to its numeric {@link DayOfWeek}. Accepts either a
|
|
21
|
-
* number (0–6) or a three-letter day name ('sun'–'sat', case-insensitive),
|
|
22
|
-
* so APIs like `weekStartsOn` can take whichever is more readable at the
|
|
23
|
-
* call site. Unrecognized values fall back to 0 (Sunday).
|
|
24
|
-
*/
|
|
25
|
-
export declare function normalizeDayOfWeek(value: DayOfWeek | DayOfWeekName): DayOfWeek;
|
|
26
14
|
/** Immutable date record with 1-based month. */
|
|
27
15
|
export interface PlainDate {
|
|
28
16
|
readonly year: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTypes.d.ts","sourceRoot":"","sources":["../../src/utils/dateTypes.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GACvB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;AAE/E,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"dateTypes.d.ts","sourceRoot":"","sources":["../../src/utils/dateTypes.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GACvB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;AAE/E,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAElD,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,0CAA0C;AAC1C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,aAAa,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC;CACpB"}
|
package/dist/utils/dateTypes.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file dateTypes.ts
|
|
5
|
-
* @input None
|
|
6
|
-
* @output Shared date type definitions used across Calendar, DateInput, and other components
|
|
7
|
-
* @position Core type definitions; imported by Calendar, DateInput, DateRangeInput, DateTimeInput, plainDate, dateParser
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* ISO 8601 date string in YYYY-MM-DD format.
|
|
12
|
-
* Example: "2026-01-28"
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** Day of week: 0 = Sunday through 6 = Saturday */
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Three-letter lowercase weekday name, 'sun' through 'sat'.
|
|
19
|
-
* A more self-documenting alternative to the numeric {@link DayOfWeek}.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** Weekday names indexed by {@link DayOfWeek} (0 = Sunday). */
|
|
23
|
-
const WEEKDAY_NAMES = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Normalize a weekday to its numeric {@link DayOfWeek}. Accepts either a
|
|
27
|
-
* number (0–6) or a three-letter day name ('sun'–'sat', case-insensitive),
|
|
28
|
-
* so APIs like `weekStartsOn` can take whichever is more readable at the
|
|
29
|
-
* call site. Unrecognized values fall back to 0 (Sunday).
|
|
30
|
-
*/
|
|
31
|
-
export function normalizeDayOfWeek(value) {
|
|
32
|
-
if (typeof value === 'number') {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
const index = WEEKDAY_NAMES.indexOf(value.toLowerCase());
|
|
36
|
-
return index === -1 ? 0 : index;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Immutable date record with 1-based month. */
|
|
40
|
-
|
|
41
|
-
/** Date range with start and end dates */
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.1.2
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"displayName": "XDS Core",
|
|
5
5
|
"description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -103,8 +103,8 @@ export const docs = {
|
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
name: 'weekStartsOn',
|
|
106
|
-
type:
|
|
107
|
-
description: 'First day of week
|
|
106
|
+
type: '0 | 1 | 2 | 3 | 4 | 5 | 6',
|
|
107
|
+
description: 'First day of week (0=Sunday).',
|
|
108
108
|
default: '0',
|
|
109
109
|
},
|
|
110
110
|
],
|
|
@@ -147,7 +147,7 @@ export const docsZh = {
|
|
|
147
147
|
{name: 'hasOutsideDays', type: 'boolean', description: '显示相邻月份的日期。', default: 'true'},
|
|
148
148
|
{name: 'hasWeekNumbers', type: 'boolean', description: '显示 ISO 周数。', default: 'false'},
|
|
149
149
|
{name: 'hasVariableRowCount', type: 'boolean', description: '可变行数与固定 6 行网格。', default: 'false'},
|
|
150
|
-
{name: 'weekStartsOn', type:
|
|
150
|
+
{name: 'weekStartsOn', type: '0 | 1 | 2 | 3 | 4 | 5 | 6', description: '每周起始日(0=周日)。', default: '0'},
|
|
151
151
|
],
|
|
152
152
|
theming: {
|
|
153
153
|
targets: [
|
|
@@ -200,6 +200,6 @@ export const docsDense = {
|
|
|
200
200
|
hasOutsideDays: 'show days from adjacent months',
|
|
201
201
|
hasWeekNumbers: 'show ISO week numbers',
|
|
202
202
|
hasVariableRowCount: 'variable vs fixed 6-row grid',
|
|
203
|
-
weekStartsOn: 'first day of week (0=Sunday
|
|
203
|
+
weekStartsOn: 'first day of week (0=Sunday)',
|
|
204
204
|
},
|
|
205
205
|
};
|
|
@@ -146,7 +146,10 @@ describe('Calendar', () => {
|
|
|
146
146
|
const handleFocusChange = vi.fn();
|
|
147
147
|
|
|
148
148
|
render(
|
|
149
|
-
<Calendar
|
|
149
|
+
<Calendar
|
|
150
|
+
focusDate="2026-01-01"
|
|
151
|
+
onFocusDateChange={handleFocusChange}
|
|
152
|
+
/>,
|
|
150
153
|
);
|
|
151
154
|
|
|
152
155
|
const nextButton = screen.getByRole('button', {name: 'Next month'});
|
|
@@ -186,7 +189,9 @@ describe('Calendar', () => {
|
|
|
186
189
|
return day !== 0 && day !== 6;
|
|
187
190
|
};
|
|
188
191
|
|
|
189
|
-
render(
|
|
192
|
+
render(
|
|
193
|
+
<Calendar focusDate="2026-01-01" dateConstraints={[isWeekday]} />,
|
|
194
|
+
);
|
|
190
195
|
|
|
191
196
|
// January 4, 2026 is a Sunday - should be disabled
|
|
192
197
|
const sunday = getDayButton(4);
|
|
@@ -233,21 +238,6 @@ describe('Calendar', () => {
|
|
|
233
238
|
expect(dayNames[0]).toHaveTextContent('Mo');
|
|
234
239
|
});
|
|
235
240
|
|
|
236
|
-
it('accepts a three-letter day name for weekStartsOn', () => {
|
|
237
|
-
render(<Calendar weekStartsOn="mon" />);
|
|
238
|
-
|
|
239
|
-
// "mon" should behave exactly like the numeric 1 (Monday first).
|
|
240
|
-
const dayNames = screen.getAllByText(/^(Mo|Tu|We|Th|Fr|Sa|Su)$/);
|
|
241
|
-
expect(dayNames[0]).toHaveTextContent('Mo');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('treats weekStartsOn day names case-insensitively', () => {
|
|
245
|
-
render(<Calendar weekStartsOn={'WED' as 'wed'} />);
|
|
246
|
-
|
|
247
|
-
const dayNames = screen.getAllByText(/^(Mo|Tu|We|Th|Fr|Sa|Su)$/);
|
|
248
|
-
expect(dayNames[0]).toHaveTextContent('We');
|
|
249
|
-
});
|
|
250
|
-
|
|
251
241
|
// ─── Range Mode ──────────────────────────────────────────────
|
|
252
242
|
|
|
253
243
|
it('supports range selection mode', async () => {
|
|
@@ -255,7 +245,11 @@ describe('Calendar', () => {
|
|
|
255
245
|
const handleChange = vi.fn();
|
|
256
246
|
|
|
257
247
|
render(
|
|
258
|
-
<Calendar
|
|
248
|
+
<Calendar
|
|
249
|
+
mode="range"
|
|
250
|
+
onChange={handleChange}
|
|
251
|
+
focusDate="2026-01-01"
|
|
252
|
+
/>,
|
|
259
253
|
);
|
|
260
254
|
|
|
261
255
|
// Click start date
|
|
@@ -277,7 +271,11 @@ describe('Calendar', () => {
|
|
|
277
271
|
const handleChange = vi.fn();
|
|
278
272
|
|
|
279
273
|
render(
|
|
280
|
-
<Calendar
|
|
274
|
+
<Calendar
|
|
275
|
+
mode="range"
|
|
276
|
+
onChange={handleChange}
|
|
277
|
+
focusDate="2026-01-01"
|
|
278
|
+
/>,
|
|
281
279
|
);
|
|
282
280
|
|
|
283
281
|
// Click later date first
|
|
@@ -348,7 +346,10 @@ describe('Calendar', () => {
|
|
|
348
346
|
const handleFocusChange = vi.fn();
|
|
349
347
|
|
|
350
348
|
render(
|
|
351
|
-
<Calendar
|
|
349
|
+
<Calendar
|
|
350
|
+
focusDate="2026-01-01"
|
|
351
|
+
onFocusDateChange={handleFocusChange}
|
|
352
|
+
/>,
|
|
352
353
|
);
|
|
353
354
|
|
|
354
355
|
// Focus Jan 28
|
|
@@ -413,7 +414,11 @@ describe('Calendar', () => {
|
|
|
413
414
|
const handleChange = vi.fn();
|
|
414
415
|
|
|
415
416
|
render(
|
|
416
|
-
<Calendar
|
|
417
|
+
<Calendar
|
|
418
|
+
mode="range"
|
|
419
|
+
onChange={handleChange}
|
|
420
|
+
focusDate="2026-01-01"
|
|
421
|
+
/>,
|
|
417
422
|
);
|
|
418
423
|
|
|
419
424
|
// Click start date to begin range selection
|
|
@@ -70,19 +70,8 @@ import {
|
|
|
70
70
|
// Types
|
|
71
71
|
// =============================================================================
|
|
72
72
|
|
|
73
|
-
export type {
|
|
74
|
-
|
|
75
|
-
DayOfWeek,
|
|
76
|
-
DayOfWeekName,
|
|
77
|
-
DateRange,
|
|
78
|
-
} from '../utils/dateTypes';
|
|
79
|
-
import type {
|
|
80
|
-
ISODateString,
|
|
81
|
-
DayOfWeek,
|
|
82
|
-
DayOfWeekName,
|
|
83
|
-
DateRange,
|
|
84
|
-
} from '../utils/dateTypes';
|
|
85
|
-
import {normalizeDayOfWeek} from '../utils/dateTypes';
|
|
73
|
+
export type {ISODateString, DayOfWeek, DateRange} from '../utils/dateTypes';
|
|
74
|
+
import type {ISODateString, DayOfWeek, DateRange} from '../utils/dateTypes';
|
|
86
75
|
import {themeProps} from '../utils/themeProps';
|
|
87
76
|
|
|
88
77
|
/** Imperative handle for Calendar handleRef */
|
|
@@ -145,11 +134,10 @@ interface CalendarBaseProps extends Omit<
|
|
|
145
134
|
hasVariableRowCount?: boolean;
|
|
146
135
|
|
|
147
136
|
/**
|
|
148
|
-
* First day of week.
|
|
149
|
-
* three-letter day name ('sun'–'sat', case-insensitive) for readability.
|
|
137
|
+
* First day of week.
|
|
150
138
|
* Default: 0 (Sunday)
|
|
151
139
|
*/
|
|
152
|
-
weekStartsOn?: DayOfWeek
|
|
140
|
+
weekStartsOn?: DayOfWeek;
|
|
153
141
|
}
|
|
154
142
|
|
|
155
143
|
// ─── Mode-specific Props (discriminated union) ────────────────
|
|
@@ -212,17 +200,13 @@ export function Calendar({ref, ...props}: CalendarProps) {
|
|
|
212
200
|
hasOutsideDays = true,
|
|
213
201
|
hasWeekNumbers = false,
|
|
214
202
|
hasVariableRowCount = false,
|
|
215
|
-
weekStartsOn
|
|
203
|
+
weekStartsOn = 0,
|
|
216
204
|
xstyle,
|
|
217
205
|
className,
|
|
218
206
|
style,
|
|
219
207
|
...rest
|
|
220
208
|
} = props;
|
|
221
209
|
|
|
222
|
-
// Normalize `weekStartsOn` (number or three-letter day name) to a numeric
|
|
223
|
-
// DayOfWeek so all downstream date math keeps working with an index.
|
|
224
|
-
const weekStartsOn = normalizeDayOfWeek(weekStartsOnProp);
|
|
225
|
-
|
|
226
210
|
// Today's date (memoized)
|
|
227
211
|
const today = useMemo(() => plainDateToday(), []);
|
|
228
212
|
|
package/src/Calendar/index.ts
CHANGED
|
@@ -40,13 +40,13 @@ export const docs = {
|
|
|
40
40
|
{
|
|
41
41
|
name: 'isOpen',
|
|
42
42
|
type: 'boolean',
|
|
43
|
-
description: 'Whether the dialog is open.',
|
|
43
|
+
description: 'Whether the dialog is open (required).',
|
|
44
44
|
required: true,
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
name: 'onOpenChange',
|
|
48
48
|
type: '(isOpen: boolean) => unknown',
|
|
49
|
-
description: 'Callback when dialog visibility changes.',
|
|
49
|
+
description: 'Callback when dialog visibility changes (required).',
|
|
50
50
|
required: true,
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -19,7 +19,7 @@ export const docs = {
|
|
|
19
19
|
name: 'onColumnResizeEnd',
|
|
20
20
|
type: '(updates: Record<string, number>) => void',
|
|
21
21
|
description:
|
|
22
|
-
'Called when a resize completes (pointerup / Enter). Receives a map of every column key whose width changed
|
|
22
|
+
'Called when a resize completes (pointerup / Enter). Receives a map of every column key whose width changed — merge it into your columnWidths state.',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: 'minWidth',
|
|
@@ -37,7 +37,7 @@ export const docs = {
|
|
|
37
37
|
name: 'columns',
|
|
38
38
|
type: 'TableColumn<T>[]',
|
|
39
39
|
description:
|
|
40
|
-
'Column definitions
|
|
40
|
+
'Column definitions — needed to derive per-column min widths and detect proportional vs pixel columns for neighbor/last-column resize behavior.',
|
|
41
41
|
},
|
|
42
42
|
],
|
|
43
43
|
};
|
|
@@ -91,6 +91,6 @@ export const docsDense = {
|
|
|
91
91
|
minWidth: 'Global min column width (px) during resize.',
|
|
92
92
|
maxWidth: 'Global max column width (px) during resize. Default Infinity.',
|
|
93
93
|
columns:
|
|
94
|
-
'Column defs
|
|
94
|
+
'Column defs — derive per-column mins + proportional/pixel detection for neighbor/last-column behavior.',
|
|
95
95
|
},
|
|
96
96
|
};
|
|
@@ -13,13 +13,13 @@ export const docs = {
|
|
|
13
13
|
name: 'startKeys',
|
|
14
14
|
type: 'string[]',
|
|
15
15
|
description:
|
|
16
|
-
'Column keys pinned to the start (inline-start / left in LTR) edge
|
|
16
|
+
'Column keys pinned to the start (inline-start / left in LTR) edge — the contiguous run from the first column through the last listed key.',
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: 'endKeys',
|
|
20
20
|
type: 'string[]',
|
|
21
21
|
description:
|
|
22
|
-
'Column keys pinned to the end (inline-end / right in LTR) edge
|
|
22
|
+
'Column keys pinned to the end (inline-end / right in LTR) edge — the contiguous run from the first listed key through the last column.',
|
|
23
23
|
},
|
|
24
24
|
],
|
|
25
25
|
};
|
package/src/utils/dateTypes.ts
CHANGED
|
@@ -17,46 +17,6 @@ export type ISODateString =
|
|
|
17
17
|
/** Day of week: 0 = Sunday through 6 = Saturday */
|
|
18
18
|
export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Three-letter lowercase weekday name, 'sun' through 'sat'.
|
|
22
|
-
* A more self-documenting alternative to the numeric {@link DayOfWeek}.
|
|
23
|
-
*/
|
|
24
|
-
export type DayOfWeekName =
|
|
25
|
-
| 'sun'
|
|
26
|
-
| 'mon'
|
|
27
|
-
| 'tue'
|
|
28
|
-
| 'wed'
|
|
29
|
-
| 'thu'
|
|
30
|
-
| 'fri'
|
|
31
|
-
| 'sat';
|
|
32
|
-
|
|
33
|
-
/** Weekday names indexed by {@link DayOfWeek} (0 = Sunday). */
|
|
34
|
-
const WEEKDAY_NAMES: ReadonlyArray<DayOfWeekName> = [
|
|
35
|
-
'sun',
|
|
36
|
-
'mon',
|
|
37
|
-
'tue',
|
|
38
|
-
'wed',
|
|
39
|
-
'thu',
|
|
40
|
-
'fri',
|
|
41
|
-
'sat',
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Normalize a weekday to its numeric {@link DayOfWeek}. Accepts either a
|
|
46
|
-
* number (0–6) or a three-letter day name ('sun'–'sat', case-insensitive),
|
|
47
|
-
* so APIs like `weekStartsOn` can take whichever is more readable at the
|
|
48
|
-
* call site. Unrecognized values fall back to 0 (Sunday).
|
|
49
|
-
*/
|
|
50
|
-
export function normalizeDayOfWeek(
|
|
51
|
-
value: DayOfWeek | DayOfWeekName,
|
|
52
|
-
): DayOfWeek {
|
|
53
|
-
if (typeof value === 'number') {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
const index = WEEKDAY_NAMES.indexOf(value.toLowerCase() as DayOfWeekName);
|
|
57
|
-
return index === -1 ? 0 : (index as DayOfWeek);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
20
|
/** Immutable date record with 1-based month. */
|
|
61
21
|
export interface PlainDate {
|
|
62
22
|
readonly year: number;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file dateTypes.test.ts
|
|
5
|
-
* @input Uses vitest
|
|
6
|
-
* @output Test suite for date type helpers
|
|
7
|
-
* @position Tests for dateTypes.ts (normalizeDayOfWeek)
|
|
8
|
-
*
|
|
9
|
-
* SYNC: When dateTypes.ts changes, update tests accordingly
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {describe, it, expect} from 'vitest';
|
|
13
|
-
import {normalizeDayOfWeek} from './dateTypes';
|
|
14
|
-
|
|
15
|
-
describe('normalizeDayOfWeek', () => {
|
|
16
|
-
it('passes numeric days through unchanged', () => {
|
|
17
|
-
expect(normalizeDayOfWeek(0)).toBe(0);
|
|
18
|
-
expect(normalizeDayOfWeek(1)).toBe(1);
|
|
19
|
-
expect(normalizeDayOfWeek(6)).toBe(6);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('maps three-letter day names to their index', () => {
|
|
23
|
-
expect(normalizeDayOfWeek('sun')).toBe(0);
|
|
24
|
-
expect(normalizeDayOfWeek('mon')).toBe(1);
|
|
25
|
-
expect(normalizeDayOfWeek('tue')).toBe(2);
|
|
26
|
-
expect(normalizeDayOfWeek('wed')).toBe(3);
|
|
27
|
-
expect(normalizeDayOfWeek('thu')).toBe(4);
|
|
28
|
-
expect(normalizeDayOfWeek('fri')).toBe(5);
|
|
29
|
-
expect(normalizeDayOfWeek('sat')).toBe(6);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('is case-insensitive for day names', () => {
|
|
33
|
-
expect(normalizeDayOfWeek('MON' as 'mon')).toBe(1);
|
|
34
|
-
expect(normalizeDayOfWeek('Sat' as 'sat')).toBe(6);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('falls back to 0 (Sunday) for an unrecognized name', () => {
|
|
38
|
-
expect(normalizeDayOfWeek('xyz' as 'mon')).toBe(0);
|
|
39
|
-
});
|
|
40
|
-
});
|