Skip to content

Commit

Permalink
feat: solved comments | updated tests and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Dias, Diego committed Aug 21, 2024
1 parent 2adc969 commit 7e5e372
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 109 deletions.
8 changes: 4 additions & 4 deletions packages/ui/src/components/Datepicker/Datepicker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ describe("Components / Datepicker", () => {
expect(screen.getByDisplayValue(todaysDateInDefaultLanguage)).toBeInTheDocument();
});

it("should call `onSelectedDateChange` when a new date is selected", async () => {
const onSelectedDateChange = vi.fn();
it("should call `onChange` when a new date is selected", async () => {
const onChange = vi.fn();
const todaysDayOfMonth = new Date().getDate();
const anotherDay = todaysDayOfMonth === 1 ? 2 : 1;

render(<Datepicker onSelectedDateChanged={onSelectedDateChange} />);
render(<Datepicker onChange={onChange} />);

await userEvent.click(screen.getByRole("textbox"));
await userEvent.click(screen.getAllByText(anotherDay)[0]);

expect(onSelectedDateChange).toHaveBeenCalledOnce();
expect(onChange).toHaveBeenCalledOnce();
});

// TODO: fix
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/Datepicker/Datepicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Template: StoryFn<DatepickerProps> = (args) => {
args.maxDate = new Date(args.maxDate);
}

// update defaultValue based on the range
// update defaultDate based on the range
if (args.minDate && args.maxDate) {
if (args.defaultDate) {
args.defaultDate = getFirstDateInRange(args.defaultDate, args.minDate, args.maxDate);
Expand Down Expand Up @@ -82,7 +82,7 @@ NullDateValue.args = {
autoHide: true,
showClearButton: true,
showTodayButton: true,
value: '',
value: "",
minDate: undefined,
maxDate: undefined,
language: "en",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Datepicker/Views/Months.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from "react";
import { twMerge } from "tailwind-merge";
import { mergeDeep } from "../../../helpers/merge-deep";
import { useDatePickerContext } from "../DatepickerContext";
import { getFormattedDate, isDateInRange, isMonthEqual, Views } from "../helpers";
import { getFormattedDate, isDateInRange, Views, isDateEqual } from "../helpers";

export interface FlowbiteDatepickerViewsMonthsTheme {
items: {
Expand Down
102 changes: 0 additions & 102 deletions src/components/Datepicker/Datepicker.spec.tsx

This file was deleted.

0 comments on commit 7e5e372

Please sign in to comment.