forked from themesberg/flowbite-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/themesberg/flowbite-react
- Loading branch information
Showing
27 changed files
with
175 additions
and
81 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss"], | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { root } from './fileInput.root'; | ||
export { dropzone } from './fileInput.dropzone'; | ||
export { helper } from './fileInput.helper'; | ||
export { multiple } from './fileInput.multiple'; | ||
export { root } from './fileInput.root'; | ||
export { sizes } from './fileInput.sizes'; | ||
export { dropzone } from './fileInput.dropzone'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { root } from './list.root'; | ||
export { unstyled } from './list.unstyled'; | ||
export { nested } from './list.nested'; | ||
export { ordered } from './list.ordered'; | ||
export { root } from './list.root'; | ||
export { unstyled } from './list.unstyled'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import userEvent from '@testing-library/user-event'; | ||
import { Banner } from './Banner'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
describe('Components / Banner', () => { | ||
it('should close when collapse button is clicked', async () => { | ||
const user = userEvent.setup(); | ||
render( | ||
<div> | ||
<Banner> | ||
<Banner.CollapseButton>Click me</Banner.CollapseButton> | ||
</Banner> | ||
</div>, | ||
); | ||
|
||
await user.tab(); | ||
await user.keyboard('[Space]'); | ||
|
||
expect(screen.queryByRole('banner')).not.toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
import { Datepicker } from './Datepicker'; | ||
import { getFormattedDate } from './helpers'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('Components / Datepicker', () => { | ||
it("should display today's date by default", () => { | ||
const todaysDateInDefaultLanguage = getFormattedDate('en', new Date()); | ||
|
||
render(<Datepicker />); | ||
|
||
expect(screen.getByDisplayValue(todaysDateInDefaultLanguage)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should update date when a different day is clicked', async () => { | ||
const todaysDayOfMonth = new Date().getDate(); | ||
const anotherDay = todaysDayOfMonth === 1 ? 2 : 1; | ||
|
||
render(<Datepicker />); | ||
|
||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getAllByText(anotherDay)[0]); | ||
|
||
expect((screen.getByRole('textbox') as HTMLInputElement).value?.includes(`${anotherDay}`)).toBeTruthy(); | ||
}); | ||
|
||
it("should reset to today's date when Clear button is clicked", async () => { | ||
const todaysDateInDefaultLanguage = getFormattedDate('en', new Date()); | ||
const todaysDayOfMonth = new Date().getDate(); | ||
const anotherDay = todaysDayOfMonth === 1 ? 2 : 1; | ||
|
||
render(<Datepicker />); | ||
|
||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getAllByText(anotherDay)[0]); | ||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getByText('Clear')); | ||
|
||
expect(screen.getByDisplayValue(todaysDateInDefaultLanguage)).toBeInTheDocument(); | ||
}); | ||
|
||
it("should use today's date when Today button is clicked", async () => { | ||
const todaysDateInDefaultLanguage = getFormattedDate('en', new Date()); | ||
const todaysDayOfMonth = new Date().getDate(); | ||
const anotherDay = todaysDayOfMonth === 1 ? 2 : 1; | ||
|
||
render(<Datepicker />); | ||
|
||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getAllByText(anotherDay)[0]); | ||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getByText('Today')); | ||
|
||
expect(screen.getByDisplayValue(todaysDateInDefaultLanguage)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call `onSelectedDateChange` when a new date is selected', async () => { | ||
const onSelectedDateChange = vi.fn(); | ||
const todaysDayOfMonth = new Date().getDate(); | ||
const anotherDay = todaysDayOfMonth === 1 ? 2 : 1; | ||
|
||
render(<Datepicker onSelectedDateChanged={onSelectedDateChange} />); | ||
|
||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(screen.getAllByText(anotherDay)[0]); | ||
|
||
expect(onSelectedDateChange).toHaveBeenCalledOnce(); | ||
}); | ||
|
||
it('should close month overlay when user clicks outside of it', async () => { | ||
render(<Datepicker />); | ||
|
||
await userEvent.click(screen.getByRole('textbox')); | ||
await userEvent.click(document.body); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.