-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from ashik-75/work
Fix issue & refactor code
- Loading branch information
Showing
12 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
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
60 changes: 60 additions & 0 deletions
60
ui/src/components/RenderProps/ListSearchResults/tests/ListSearchResult.test.tsx
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,60 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import ListSearchResults from "components/RenderProps/ListSearchResults"; | ||
import { API_ERROR, API_LOADING, API_NO_DATA } from "lib/utils/constants"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
|
||
describe("ListSearchResults Component", () => { | ||
it("renders an error message when isError is true", () => { | ||
render( | ||
<MemoryRouter> | ||
<ListSearchResults | ||
items={[]} | ||
resourceName="news" | ||
itemComponent={() => <div>Item Component</div>} | ||
isLoading={false} | ||
isError={true} | ||
/> | ||
</MemoryRouter> | ||
); | ||
|
||
const errorMessage = screen.getByText(API_ERROR); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders a 'No Data' message when there are no items and isError is false", () => { | ||
render( | ||
<MemoryRouter> | ||
<ListSearchResults | ||
items={[]} | ||
resourceName="news" | ||
itemComponent={() => <div>Item Component</div>} | ||
isLoading={false} | ||
isError={false} | ||
/> | ||
</MemoryRouter> | ||
); | ||
|
||
const noDataMessage = screen.getByText(API_NO_DATA); | ||
expect(noDataMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders loading state when isLoading is true", () => { | ||
render( | ||
<MemoryRouter> | ||
<ListSearchResults | ||
items={[]} | ||
resourceName="news" | ||
itemComponent={() => <div>Item Component</div>} | ||
isLoading={true} | ||
isError={false} | ||
/> | ||
</MemoryRouter> | ||
); | ||
|
||
const loadingElement = screen.queryByDisplayValue(API_LOADING); | ||
const noDataMessage = screen.queryByDisplayValue(API_NO_DATA); | ||
|
||
expect(loadingElement).not.toBeInTheDocument(); | ||
expect(noDataMessage).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
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,13 +1,17 @@ | ||
enum AvatarShape { | ||
Circle = "circle", | ||
Square = "square", | ||
Custom = "custom", | ||
} | ||
const AvatarShape = { | ||
Circle: "circle", | ||
Square: "square", | ||
Custom: "custom", | ||
}; | ||
|
||
type AvatarShapeType = (typeof AvatarShape)[keyof typeof AvatarShape]; | ||
|
||
const AVATAR_SHAPE_SEGMENTED_OPTIONS = [ | ||
{ label: "Circle", value: AvatarShape.Circle }, | ||
{ label: "Square", value: AvatarShape.Square }, | ||
{ label: "Custom", value: AvatarShape.Custom }, | ||
]; | ||
|
||
export type { AvatarShapeType }; | ||
|
||
export { AVATAR_SHAPE_SEGMENTED_OPTIONS, AvatarShape }; |
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 |
---|---|---|
|
@@ -26,5 +26,6 @@ | |
display: grid; | ||
row-gap: 10px; | ||
grid-template-columns: 1fr; | ||
overflow-x: auto; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
ui/src/pages/Markdown/TableOfContent/TableOfContent.module.scss
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,7 @@ | ||
.toc { | ||
height: calc(100dvh - 70px); | ||
overflow: hidden; | ||
|
||
&__output { | ||
display: grid; | ||
gap: var(--bt-size-30); | ||
|
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,9 @@ | ||
import { render } from "@testing-library/react"; | ||
import { News } from "pages/pages"; | ||
import { describe, test } from "vitest"; | ||
|
||
describe("test news component", () => { | ||
test("render component withoud crash", () => { | ||
render(<News />); | ||
}); | ||
}); |