Skip to content

Commit

Permalink
Fix case #1
Browse files Browse the repository at this point in the history
Signed-off-by: gpbl <io@gpbl.dev>
  • Loading branch information
gpbl committed May 5, 2024
1 parent 1b715f2 commit 4244559
Show file tree
Hide file tree
Showing 108 changed files with 4,516 additions and 68 deletions.
147 changes: 79 additions & 68 deletions website/examples/__snapshots__/Range.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`should match the snapshot 1`] = `
>
<div
class="rdp "
id="test"
>
<div
class="rdp-months"
Expand All @@ -20,10 +21,10 @@ exports[`should match the snapshot 1`] = `
<div
aria-live="polite"
class="rdp-caption_label"
id=":r0:-0"
id="test-0"
role="presentation"
>
May 2024
November 2020
</div>
<div
class="rdp-nav"
Expand Down Expand Up @@ -68,8 +69,9 @@ exports[`should match the snapshot 1`] = `
</div>
</div>
<table
aria-labelledby=":r0:-0"
aria-labelledby="test-0"
class="rdp-table"
id="test-grid-0"
role="grid"
>
<thead
Expand Down Expand Up @@ -135,30 +137,6 @@ exports[`should match the snapshot 1`] = `
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
role="presentation"
Expand Down Expand Up @@ -215,20 +193,15 @@ exports[`should match the snapshot 1`] = `
4
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
>
<button
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_today rdp-day_range_start"
class="rdp-button_reset rdp-button rdp-day"
name="day"
role="gridcell"
tabindex="0"
tabindex="-1"
type="button"
>
5
Expand All @@ -239,8 +212,7 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
class="rdp-button_reset rdp-button rdp-day"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -254,8 +226,7 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
class="rdp-button_reset rdp-button rdp-day"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -264,13 +235,16 @@ exports[`should match the snapshot 1`] = `
7
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
>
<button
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
class="rdp-button_reset rdp-button rdp-day"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -284,8 +258,7 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_end"
class="rdp-button_reset rdp-button rdp-day"
name="day"
role="gridcell"
tabindex="-1"
Expand Down Expand Up @@ -322,10 +295,6 @@ exports[`should match the snapshot 1`] = `
11
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
Expand Down Expand Up @@ -368,15 +337,20 @@ exports[`should match the snapshot 1`] = `
14
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_start"
name="day"
role="gridcell"
tabindex="-1"
tabindex="0"
type="button"
>
15
Expand All @@ -387,7 +361,8 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -401,7 +376,8 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -415,7 +391,8 @@ exports[`should match the snapshot 1`] = `
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_middle"
name="day"
role="gridcell"
tabindex="-1"
Expand All @@ -424,16 +401,13 @@ exports[`should match the snapshot 1`] = `
18
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
aria-selected="true"
class="rdp-button_reset rdp-button rdp-day rdp-day_selected rdp-day_range_end"
name="day"
role="gridcell"
tabindex="-1"
Expand Down Expand Up @@ -470,6 +444,10 @@ exports[`should match the snapshot 1`] = `
21
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
Expand Down Expand Up @@ -526,10 +504,6 @@ exports[`should match the snapshot 1`] = `
25
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
Expand Down Expand Up @@ -572,6 +546,10 @@ exports[`should match the snapshot 1`] = `
28
</button>
</td>
</tr>
<tr
class="rdp-row"
>
<td
class="rdp-cell"
role="presentation"
Expand Down Expand Up @@ -604,15 +582,33 @@ exports[`should match the snapshot 1`] = `
class="rdp-cell"
role="presentation"
>
<button
class="rdp-button_reset rdp-button rdp-day"
name="day"
<div
role="gridcell"
tabindex="-1"
type="button"
>
31
</button>
/>
</td>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
role="presentation"
>
<div
role="gridcell"
/>
</td>
<td
class="rdp-cell"
Expand All @@ -624,6 +620,21 @@ exports[`should match the snapshot 1`] = `
</td>
</tr>
</tbody>
<tfoot
class="rdp-tfoot"
>
<tr>
<td
colspan="8"
>
<p>
November 15th, 2020
November 19th, 2020
</p>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
Expand Down
23 changes: 23 additions & 0 deletions website/examples2/ContainerAttributes.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { app, renderApp } from "@/test";

import { ContainerAttributes } from "./ContainerAttributes";

beforeEach(() => {
renderApp(<ContainerAttributes />);
});

test('should have the "id" attribute', () => {
expect(app().firstChild).toHaveAttribute("id", "testId");
});

test('should have the "title" attribute', () => {
expect(app().firstChild).toHaveAttribute("title", "foo_title");
});

test('should have the "lang" attribute', () => {
expect(app().firstChild).toHaveAttribute("lang", "it");
});

test("should have the data set attribute", () => {
expect(app().firstChild).toHaveAttribute("data-test", "testData");
});
20 changes: 20 additions & 0 deletions website/examples2/ContainerAttributes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DayPicker } from "react-day-picker";

/**
* Pass selected HTML attributes and `data-` attributes to the root element.
*
* @exampleTitle Container Attributes
*/
export function ContainerAttributes() {
return (
<DayPicker
id="testId"
className="testClass"
data-test="testData"
nonce="foo_nonce"
title="foo_title"
lang="it"
mode="multiple"
/>
);
}
21 changes: 21 additions & 0 deletions website/examples2/Controlled.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { act, screen } from "@testing-library/react";

import { mockDate, grid, renderApp, user } from "@/test";

import { Controlled } from "./Controlled";

mockDate(new Date(2022, 5, 10));

describe('when the "Today" button is clicked', () => {
const todayButton = () => screen.getByRole("button", { name: "Go to Today" });
beforeEach(async () => {
renderApp(<Controlled />);
await act(() => user.click(todayButton()));
});
test("the button should be disabled", async () => {
expect(todayButton()).toBeDisabled();
});
test("should display the current month", () => {
expect(grid()).toHaveAccessibleName("June 2022");
});
});
Loading

0 comments on commit 4244559

Please sign in to comment.