UNPKG

1.95 kBTypeScriptView Raw
1import React from "react";
2
3import { DayPicker } from "../DayPicker";
4
5import { DateRange } from "./shared";
6
7const Test = () => {
8 return (
9 <>
10 <DayPicker />
11 <DayPicker mode="single" />
12 <DayPicker
13 mode="single"
14 selected={undefined}
15 onSelect={(date: Date | undefined) => {}}
16 />
17 <DayPicker
18 mode="single"
19 selected={new Date()}
20 onSelect={(date: Date | undefined) => {}}
21 />
22 {/* @ts-expect-error Missing `selected` */}
23 <DayPicker
24 mode="single"
25 required
26 onSelect={(date: Date | undefined) => {}}
27 />
28 {/* Allow undefined as initial selected value */}
29 <DayPicker mode="single" required selected={undefined} />
30 <DayPicker
31 mode="multiple"
32 required
33 selected={undefined}
34 onSelect={(selected: Date[], date: Date, modifiers) => {}}
35 />
36 <DayPicker
37 mode="range"
38 required
39 selected={undefined}
40 onSelect={(selected: DateRange, date: Date, modifiers) => {}}
41 />
42 <DayPicker
43 mode="multiple"
44 required={false}
45 selected={undefined}
46 // @ts-expect-error Selected can be also undefined
47 onSelect={(selected: Date[], date: Date, modifiers) => {}}
48 />
49 {/** @ts-expect-error Wrong selected prop */}
50 <DayPicker mode="multiple" selected={new Date()} />
51 <DayPicker mode="multiple" onSelect={(date: Date[] | undefined) => {}} />
52 <DayPicker
53 mode="multiple"
54 required
55 selected={[]}
56 onSelect={(date: Date[]) => {}}
57 />
58 <DayPicker mode="single" selected={new Date()} />
59 <DayPicker modifiers={{ selected: new Date() }} onDayClick={() => {}} />
60 <DayPicker
61 onSelect={() => {}}
62 selected={new Date()}
63 onDayClick={() => {}}
64 />
65 </>
66 );
67};
68
69it("should type-check", () => {
70 expect(Test).toBeTruthy();
71});