-
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' into feature/images-format
- Loading branch information
Showing
9 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,28 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import Loading from "./Loading"; | ||
import { ThemeProvider } from "styled-components"; | ||
import mainTheme from "../../styles/mainTheme"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import UiContextWrapper from "../../features/Ui/store/UiContextWrapper"; | ||
|
||
describe("Given a Loading component", () => { | ||
describe("When is render", () => { | ||
test("Then it should show `logo loading page`", () => { | ||
const expectedAltText = "logo loading page"; | ||
const expectedImageSrc = "public/images/logo.png"; | ||
|
||
render( | ||
<BrowserRouter> | ||
<UiContextWrapper> | ||
<ThemeProvider theme={mainTheme}> | ||
<Loading /> | ||
</ThemeProvider> | ||
</UiContextWrapper> | ||
</BrowserRouter>, | ||
); | ||
|
||
const loadImage = screen.getByAltText(expectedAltText); | ||
expect(loadImage).toHaveAttribute("src", expectedImageSrc); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
const Loading = (): React.ReactElement => { | ||
return ( | ||
<div> | ||
<img src="public/images/logo.png" alt="logo loading page"></img> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
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,6 @@ | ||
import { createContext } from "react"; | ||
import UiContextStructure from "./types"; | ||
|
||
const UiContext = createContext<UiContextStructure>({} as UiContextStructure); | ||
|
||
export default UiContext; |
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,13 @@ | ||
import UiContext from "./UiContext"; | ||
import { PropsWithChildren, useMemo, useState } from "react"; | ||
|
||
const UiContextWrapper = ({ | ||
children, | ||
}: PropsWithChildren): React.ReactElement => { | ||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||
const uiValue = useMemo(() => ({ isLoading, setIsLoading }), [isLoading]); | ||
|
||
return <UiContext.Provider value={uiValue}>{children}</UiContext.Provider>; | ||
}; | ||
|
||
export default UiContextWrapper; |
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,6 @@ | ||
interface UiContextStructure { | ||
isLoading: boolean; | ||
setIsLoading: (isLoading: boolean) => void; | ||
} | ||
|
||
export default UiContextStructure; |
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