-
Notifications
You must be signed in to change notification settings - Fork 1
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 #46 from abolfazlcodes/stage
Stage
- Loading branch information
Showing
11 changed files
with
210 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,26 @@ | ||
import { render } from "../../../utilities"; | ||
import { screen } from "@testing-library/react"; | ||
import Header from "../ui/Header"; | ||
|
||
describe("Header Component Tests Suite", () => { | ||
it("should render the header component", () => { | ||
render(<Header title="Work" />); | ||
}); | ||
|
||
it("should render the header component with the corresponding title", () => { | ||
render(<Header title="Work" />); | ||
|
||
const titleElement = screen.getByTestId("header-text"); | ||
expect(titleElement).toBeInTheDocument(); | ||
expect(titleElement).toHaveTextContent(/work/i); | ||
}); | ||
|
||
it("should render the link if there is a href and linkText props", () => { | ||
render(<Header title="Work" href="/work" linkText="see work" />); | ||
|
||
const linkElement = screen.getByRole("link", { name: /see work/i }); | ||
|
||
expect(linkElement).toBeInTheDocument(); | ||
expect(linkElement).toHaveAttribute("href", "/work"); | ||
}); | ||
}); |
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,39 @@ | ||
import { render } from "../../../utilities"; | ||
import Section from "../ui/Section"; | ||
import { screen } from "@testing-library/react"; | ||
|
||
describe("Section Component Test Suite", () => { | ||
it("should render the section component", () => { | ||
render( | ||
<Section> | ||
<span>section child</span> | ||
</Section>, | ||
); | ||
}); | ||
|
||
it("should render the section component with Ellipsis if hasEllipse props is true and type of primary", () => { | ||
render( | ||
<Section type="primary" hasEllipse> | ||
<span>section child</span> | ||
</Section>, | ||
); | ||
|
||
const sectionElement = screen.getByTestId("section-component"); | ||
|
||
expect(sectionElement).toBeInTheDocument(); | ||
expect(sectionElement).toHaveClass("ellipse"); | ||
}); | ||
|
||
it("should render the section component without Ellipsis if hasEllipse props is false and type of primary", () => { | ||
render( | ||
<Section type="primary"> | ||
<span>section child</span> | ||
</Section>, | ||
); | ||
|
||
const sectionElement = screen.getByTestId("section-component"); | ||
|
||
expect(sectionElement).toBeInTheDocument(); | ||
expect(sectionElement).not.toHaveClass("ellipse"); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"composite": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"allowSyntheticDefaultImports": true | ||
}, | ||
"include": ["vite.config.ts"] | ||
} |
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,16 @@ | ||
// import type { ReactElement } from 'react'; | ||
|
||
import userEvent from "@testing-library/user-event"; | ||
import { ReactElement } from "react"; | ||
import { render as renderComponent } from "@testing-library/react"; | ||
|
||
export * from "@testing-library/react"; | ||
|
||
type TRenderOptionProps = Parameters<typeof renderComponent>[1]; | ||
|
||
export const render = (ui: ReactElement, option?: TRenderOptionProps) => { | ||
return { | ||
...renderComponent(ui, option), | ||
user: userEvent.setup(), | ||
}; | ||
}; |
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